---
title: "How to format JSON online | ToolSugar"
description: "Format, minify and validate JSON in your browser, pick an indent, and find the line and column of the first syntax error."
canonical: https://toolsugar.com/blog/how-to-format-json
image: https://toolsugar.com/og.png
---

# How to format and validate JSON in your browser

Updated 2026-11-09

To format JSON, paste it into a formatter and choose an indent. JSON Formatter on ToolSugar runs in your browser, so your text stays on your device. It pretty prints, minifies or validates, and the result updates as you type. When the JSON is broken, it names the line and column of the first error.

[Open JSON Formatter](https://toolsugar.com/tools/json-formatter)

## Format JSON in four steps

You can paste text or load a .json file. The output appears beside the input with no button to press.

1. Paste JSON into the JSON box, or use the open a file link to load a .json file.
2. Under Action, choose Format, Minify or Validate.
3. For Format, pick 2 spaces, 4 spaces or Tab under Indent.
4. Read the result, then copy it or download it.

## What format, minify and validate do

Format adds line breaks and indentation so each key sits on its own line. Minify does the reverse and removes every space it can, which suits a payload you want to embed in a request or a config string.

Validate only checks the text and tells you whether it parses. Whitespace carries no meaning in JSON, so a 2 space, 4 space or tab version of the same data is equivalent. Format and minify keep key order, with one exception. A key that is a plain whole number, such as "2", moves to the front of its object, because JavaScript orders object keys that way.

## How to find the error in broken JSON

The red message starts with the line and column of the first problem, then says what the parser expected. Go to that spot first. A parser stops at the first failure, so fix it and check again, because a second problem may sit further down.

The usual causes are a comma after the last item, single quotes around a string, a key without quotes, and a comment. Strict JSON allows none of these, and the tool does not guess what you meant.

## When numbers and keys change

Formatting leaves most values alone. An integer beyond 9,007,199,254,740,991 loses digits, because the browser reads numbers as doubles. If an ID is that long, keep it as a string in the source. Numbers are also rewritten in their shortest form, so 1.0 becomes 1 and 1.10 becomes 1.1.

If the same key appears twice in one object, only the last value survives. Check for this when a field seems to hold the wrong value after formatting.

## Questions

### Which indent should I choose?

Use whatever your team or your editor expects. Two spaces keeps long documents narrow, four spaces is common in other languages, and a tab lets each reader set the width. The data is the same in each case.

### Why does my JSON with comments fail?

JSON has no comment syntax. Remove the comments, or keep a separate copy with notes. The error shows the line and column where the first one starts.

### Can I load a file instead of pasting?

Yes. Use the open a file option to load a .json file, then download the formatted version when you are done.

[Open JSON Formatter](https://toolsugar.com/tools/json-formatter)

## Related guides

- [How to convert JSON to YAML](https://toolsugar.com/blog/how-to-convert-json-to-yaml)
- [How to convert JSON to CSV](https://toolsugar.com/blog/how-to-convert-json-to-csv)
- [How to convert YAML to JSON](https://toolsugar.com/blog/how-to-convert-yaml-to-json)
- [How to format SQL queries](https://toolsugar.com/blog/how-to-format-sql)
