Format a JSON File Without Uploading It
Choose the JSON file, select readable output and use two spaces unless the project requires another indent. The document is validated, optional whitespace is rewritten, and a new .json file is created locally without sending its contents to a server.
A UTF-8 JSON document up to 25 MB. Its bytes stay in this browser tab.
Results are provided as-is, with no warranty of accuracy. The method and its sources are published below so you can check the working.
Readable mode inserts line breaks and indentation only outside JSON strings.
Number tokens, key order, duplicate keys and string escape spelling remain unchanged.
Invalid UTF-8 or invalid JSON is refused rather than partially rewritten.
How it works
How it is done
- Read the file as strict UTF-8. Accept and consume an initial UTF-8 byte-order mark for compatibility, but do not write one into the result.
- Validate the complete document as one RFC 8259 JSON value before producing an artifact. Refuse an empty file, invalid UTF-8, trailing content or malformed objects, arrays, strings, numbers and literal names.
- Scan the validated source while tracking quoted strings and backslash escapes. Inside a string, copy every code unit exactly; outside a string, discard only space, tab, carriage return and line feed.
- For readable output, insert the selected indentation after an opening container and comma, one space after a colon, and a correctly indented line before a non-empty closing container. For minified output, insert no optional whitespace.
- Encode the rewritten text as UTF-8, add one final line feed only when selected, and offer a new .json file. Never parse number tokens into floating-point values for output.
What it assumes
- Formatting is not canonicalisation. Object member order, duplicate names, number spelling and string escape choices stay as authored even where another parser might normalise or collapse them.
- JSON exchanged between independent systems is UTF-8 under RFC 8259. UTF-16 and legacy code pages belong in the separate text-encoding converter before this grammar is applied.
- The native JSON parser is used as a strict grammar validator only. The downloadable bytes come from a token-preserving scan of the original text, not from JSON.stringify.
- Input is capped at 25 MB. The rewrite yields every 250,000 characters so progress and Cancel remain responsive; native validation itself is intentionally left to the browser's optimised parser.
Common questions
Can formatting JSON round a large integer?
This formatter does not parse numbers into JavaScript Number values before writing them. It validates the document, then carries each original number token through unchanged.
Does readable JSON mean the keys are sorted?
No. Formatting changes optional whitespace, not object member order. Existing order and even duplicate member names stay in their original sequence.
Sources
The full method, worked example and every assumption behind this figure are on JSON Formatter.