# JSON Formatter & Validator - Free, Local

Page: https://hirantha.me/tools/json-formatter
Part of: Hirantha Sandaruwan Lakshan free tools (https://hirantha.me/tools)
Updated: 2026-07-31

Pretty-print, minify, and validate JSON with clear error locations.

This is a free tool that runs in the browser: open the page to use it. File tools process files on the visitor's own device; files are never uploaded or stored. No account, sign-up, payment or watermark.

Paste JSON to format it with indentation, minify it to a single line, or check it's valid. Invalid JSON is flagged with the exact position of the problem, entirely in your browser.

The text is parsed with the browser's built-in JSON parser. If parsing fails, the error message and character position are shown directly rather than a generic 'invalid JSON' notice.

Formatting re-serialises the parsed result with two-space indentation, producing consistent output regardless of how the original was spaced or minified.

Minifying does the same parse-and-reserialise step with no indentation, useful for pasting JSON into a context where whitespace costs bytes, like a URL parameter or a compact config file.

Q: Is my JSON uploaded anywhere?
A: No, parsing and formatting both happen entirely in your browser tab.

Q: What happens if my JSON is invalid?
A: The parser's error message is shown along with the position in the text where it failed, rather than a vague failure notice.

Q: Does this support JSON with comments?
A: No - standard JSON doesn't allow comments, so a file with them will fail to parse here, matching how most JSON consumers behave.

Q: Is there a size limit?
A: No fixed limit - very large documents are bound only by your browser's available memory.

Q: Can it minify JSON as well as format it?
A: Yes, minifying strips all the whitespace back out to give the smallest valid representation, which is what you'd send over the network.

Q: Does it sort keys alphabetically?
A: No. Key order is preserved exactly as written, because reordering would change the file in a way that isn't always safe or wanted.

Q: Why does it reject my JSON when it looks fine?
A: The usual culprits are trailing commas after the last item, single quotes instead of double quotes, or unquoted keys. All three are valid JavaScript but not valid JSON.

Q: Can it handle very large JSON files?
A: Large documents work, but parsing and re-rendering many megabytes of JSON will make the browser sluggish. It's built for the payloads you're debugging, not for bulk data processing.

Sources: JSON - Wikipedia (https://en.wikipedia.org/wiki/JSON); JSON.parse() - MDN (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse)

Related tools:

- [Base64 encode & decode](https://hirantha.me/tools/base64.md): Convert text to Base64 and back, right in your browser.
- [Regex tester](https://hirantha.me/tools/regex-tester.md): Test a regular expression against sample text and see every match.
- [Colour converter](https://hirantha.me/tools/color-converter.md): Convert a colour between HEX, RGB, and HSL.
- [JSON to CSV converter](https://hirantha.me/tools/json-to-csv-converter.md): Convert JSON to CSV in your browser. Flattens nested objects, joins or numbers arrays, quotes fields per RFC 4180 and downloads a file Excel can open.
- [CSV to JSON converter](https://hirantha.me/tools/csv-to-json-converter.md): Convert CSV to JSON in your browser. Handles quoted fields and line breaks per RFC 4180, detects the delimiter, and keeps values like 007 as text.
- [URL parser](https://hirantha.me/tools/url-parser.md): Split any URL into protocol, host, port, path, query parameters and fragment. Decodes percent-encoding, flags tracking parameters and rebuilds the URL.
