How to use JSON Formatter and Validator
- Paste your JSON into the JSON box.
- Choose Format and indent, Minify or Validate only in Action.
- Pick an Indentation if you are formatting.
- The formatted, minified or validated result updates as you change the JSON. Copy it or read the error line and column.
Example: JSON Formatter and Validator
Format a small object with three keys.
Options
- Action
- Format and indent rewrites the document with line breaks, Minify removes every optional space, and Validate only reports whether the JSON is valid without producing any output.
- Sort object keys alphabetically
- Reorders the keys of every object, at any depth, before formatting or minifying. Array order is never changed. Useful when you want two JSON files to diff cleanly.
- Collapsible tree
- Open individual objects and arrays, choose an expansion depth or collapse the visible tree. The preview is bounded to 1,000 nodes and 40 levels and shortens long values. Copy and download contain the complete formatted or minified JSON.
Supported inputs and limits
Where your input is processed
This tool processes your input in this browser. Your text and files are not uploaded to UseFreeTools. Check this tool's limits for anything it may save on your device.
Why long numbers change when JSON is formatted
JSON itself puts no limit on how long a number can be. The limit comes from the tools that read it. This tool parses JSON with JavaScript, which stores numbers as 64-bit floating point values and holds about 15 or 16 significant digits exactly. A bank account number or a long order ID is often longer, so parsing it into a number silently rounds the tail. The safe rule: if a value is an identifier rather than something you do arithmetic on, send it as a string. Formatted JSON keeps strings untouched, so no digits are lost.
Questions about JSON Formatter and Validator
Why did a long ID in my JSON change?
JavaScript can round a 17-digit numeric ID when it parses the document. Store exact IDs as strings before formatting.
Can I format JSON that contains comments or trailing commas?
No. Both are outside the JSON specification, so the parser rejects them. Remove the comments, or convert the file to a format that allows them, before pasting it here.
What does Validate only tell me when the JSON is good?
It reports the root value, such as an object with 4 keys or an array with 12 items, and a table counting objects, arrays, strings, numbers, booleans, null values, keys and the deepest nesting. It does not print the document back.
Does formatting change my data?
String values and keys keep their text, but the spelling of an escaped character can change, so an accented letter written as an escape may come back as the letter itself. Numbers are written in their shortest form, so 1.50 becomes 1.5 and 1e2 may become 100. Key order stays as you wrote it unless you turn on sorting.
How precise is the error position?
The tool reports a line and a column, and falls back to its own scanner when the browser's error message omits a position. Treat the position as a starting point, since the real problem is sometimes one line earlier, such as a missing comma.