JSON Formatter
Paste one long line of JSON and get it neatly laid out at once. Pick 2-space, 4-space, or tab indentation, or minify it to one line, sort keys, and check the syntax. Big numbers stay exact, and formatting never changes a value.
Formatted result
Paste or open some JSON and the result appears here instantly.
How to Use
- Paste JSON into the top box and the neatly laid-out result appears below as you go, with no button to press. A one-line API response becomes readable right away.
- Choose 2 spaces, 4 spaces, or Tab for indentation. “Minify” removes every extra space and line break, which suits an environment variable or an API request. It only shrinks the text and has nothing to do with zip-style file compression.
- Turn on “Sort keys” to order the keys of every object alphabetically while leaving arrays as they are, which makes two configs easier to compare.
- Above the result you'll see the size before and after, counted in UTF-8 bytes and shown as B, KB, or MB, so you can tell how much minifying saved.
- If the syntax is wrong, the tool shows the line and column, quotes that line, and marks the spot with ^. “Select the problem” highlights that part for you, so it works as a JSON validator too. While the input has an error, the result box stays empty.
- Click “Choose a file” or drop a file (up to 5 MB) into the top box to read a .json or other text file and format it at once. Non-UTF-8 files fall back to Windows-1252 on English pages, and you can switch the text encoding manually if anything looks garbled.
- “Download” saves the result as a JSON file with LF line endings: it keeps the base filename of an opened file, or uses data.json for pasted text. “Copy” puts the result on the clipboard.
- JSON with comments or trailing commas, such as tsconfig.json, can be formatted too. The result is standard JSON, with a note that lenient mode was used and that comments were removed. A duplicate key in the same object gets a warning with its line number.
- Switch the result to the “Tree” tab for a code-editor-style view with line numbers. Tap › next to a line number to expand or collapse that level. Folded objects and arrays show as {…} with their item count, and keys and values are colored by type: strings in quotes, numbers exactly as written. The first two levels open by default. “Expand all” only opens the parts you've already visited, and “Collapse all” goes back to the top level. The tool remembers whether you last used Text or Tree.
- In the tree, tap a node to copy its JSONPath, such as $.users[0].name. Keys with spaces or symbols are written like $["first name"]. With a keyboard, the up and down arrows move, left and right collapse and expand, and Enter copies the path. Arrays with more than 100 items are split into groups of 100, so tens of thousands of entries stay smooth to browse even on a phone.
- To turn JSON into YAML, TOML, CSV, XML, or another data format, use the converters listed under related tools below this page.
FAQ
Will formatting change my data or any number?
No. Formatting only adjusts indentation, line breaks, and (if you turn it on) key order. The data itself stays the same. Many tools rely on the browser's built-in JSON parser, which rounds integers beyond 2⁵³ (about 9 quadrillion) and long decimals. This tool parses JSON itself and writes every number back exactly as written, so 12345678901234567890 and 1.50 don't change. The only difference in spelling is escapes inside strings: \u0041 is written as A, which is the same value. Only an oversized integer in lenient mode or a duplicate key in one object (the last one wins) can change anything, and both come with a warning.
Can I use this as a JSON validator?
Yes. If the syntax is wrong, the tool shows the line and column, quotes that line, and marks the spot with ^. Common mistakes such as a missing comma, an upper-case True, or a missing closing bracket each get an explanation. When there is no error, the result appears below. If the input has comments or trailing commas, the tool switches to lenient mode and tells you, so seeing the lenient-mode note means the content isn't standard JSON.
Why did my comments disappear?
Standard JSON has no comment syntax. Files such as tsconfig.json often contain comments, but the formatted result is standard JSON and doesn't keep them. The tool warns you whenever comments are removed, so back up the comments before saving the result over the original file.
How does “Sort keys” sort, and does it touch arrays?
It sorts the keys of every object recursively by Unicode code point, so upper-case letters come before lower-case ones. Arrays keep their order, because the order of an array is part of the data. It's off by default, which leaves keys in your original order.
What happens with duplicate keys in one object?
The JSON standard doesn't forbid duplicate keys, but most programs keep only the last one. The tool follows the same rule, keeps the last value, and warns you with the path and line number so you can find values that were silently overridden in a config file.
Which files and text encodings are supported?
Text files up to 5 MB can be opened, whatever the extension. Files are decoded as UTF-8 (with any BOM stripped) first, falling back to Windows-1252 on English pages if invalid, with a menu to re-read as UTF-8, Big5, Shift_JIS, or Windows-1252. Downloaded results are always UTF-8.
What JSONPath format does the tree view copy?
Paths start with $ for the top level. Keys made of letters, digits, underscores, or $ that don't start with a digit use dot notation, such as $.users[0].name. Keys with spaces, symbols, non-ASCII characters, or an empty key use brackets and double quotes, such as $["first name"]. Array items use brackets with the index. Most JSONPath tools accept this as is, and in JavaScript you can swap the leading $ for your variable name. Tapping a group row copies the path of the whole array.
Will the tree view slow down with a large JSON file?
It never draws the whole document at once. Child nodes are only created when you expand them, and arrays with more than 100 items are split into groups of 100, such as [0…99] and [100…199], so an array with tens of thousands of entries first shows only its groups. “Expand all” only opens what has already been created rather than the entire file. Files near the 5 MB limit stay smooth to browse, even on a phone.
Related Tools
Data Format Converter
Pick a data format for each box and convert between any two of JSON, YAML, TOML, INI, .env, properties, CSV, and XML, such as application.properties to YAML, .env to JSON, or CSV to XML. Anything lost along the way is flagged one by one, all in your browser.
JSON to YAML Converter
Paste into either box to convert JSON to YAML or YAML back to JSON. Big numbers stay exact, and every lost detail gets its own warning.
JSON to TOML Converter
Paste text or open a file in either box to convert between JSON and TOML (including pyproject.toml and Cargo.toml), with per-path warnings for any lost details.
JSON to CSV Converter
Paste text or open a file in either box to convert between a JSON array and CSV. Nested fields are flattened with a warning, and downloaded CSV gets a BOM so Excel shows non-English text correctly.
JSON to XML Converter
Paste text or open a file in either box to turn legacy XML into JSON or JSON into valid XML with a declaration, with clear rules for attributes, text, and repeated elements.
Unicode Escape Encoder & Decoder
Type in either box to turn text into \uXXXX, \u{…}, &#x…;, or U+XXXX, or decode any mix of Unicode escapes back into text.
Base64 Encoder & Decoder
Type in either box to encode text as Base64 or decode Base64 back into text. UTF-8 safe, with a URL-safe alphabet option.