{ / }Stack NotesTHE SMALL WEB TOOLKITTry a free tool ↗
Developer tools · FIELDNOTES

How to Format JSON Locally Without Losing Important Data

Format, validate, or minify JSON in your browser. Your document stays on this page.

Start with the kind of input you actually have

A JSON formatter is useful when an API response is valid but difficult to inspect. It cannot turn every JavaScript expression into JSON. Before changing the text, identify whether you have a JSON document, a JavaScript object literal, a line-delimited stream, or a string that contains an encoded document. These formats look similar, but they require different handling.

For example, {"active":true} is JSON. {active:true} is not: JSON property names need double quotes. A trailing comma after the last property is another common cause of failure. Remove one error at a time and keep an untouched copy, especially when investigating an API bug. Making a broken example look tidy is not the same as finding its cause.

A repeatable local workflow

Start with a small representative sample. Paste it into the formatter, use Format, and read the nesting before copying the result. If parsing fails, check the location described by your browser’s parser. Error wording varies between browsers, so the important evidence is the input and the failing structure, not the exact phrasing of the error message.

Try a top-level array as well as an object. Then check an empty object, a null value, an escaped quote, and a non-English string. These cases catch assumptions hidden by simple examples. Use Minify only after the document parses. It removes insignificant whitespace, not data fields, and is not a substitute for compression over the network.

Know where precision can disappear

This tool uses JavaScript’s built-in JSON parser. Ordinary JavaScript numbers cannot exactly represent every large integer. An account or event identifier that looks like a number may therefore need to be stored as a string. The formatter rejects unsafe unquoted integers instead of silently changing an ID. It also rejects documents larger than 200 KB to keep the page responsive.

Duplicate property names are a separate issue. A document such as {"role":"reader","role":"editor"} leaves only the last value after JSON.parse. The formatter is not a duplicate-key auditor. If you must preserve exact bytes, signatures, numeric spelling, or duplicate entries, keep the original document and use a parser designed for that requirement.

A small verification table

InputExpected resultWhat it checks
{"active":true}An indented objectBasic valid JSON
{"name":"工具"}Text stays readableUnicode handling
{"id":"9007199254740993"}ID remains a stringIdentifier preservation
{"value":1,}Validation errorTrailing-comma rejection

Keep sensitive material out of your test cases

Formatting runs on this page, without uploading the document. That does not make every browsing environment private: extensions, shared computers, and screen recording can still matter. Replace live credentials and customer records with synthetic examples before debugging. When sharing a problem, include the smallest input that demonstrates it and the expected structure, rather than an entire production response.

The useful outcome is a document you understand and can reproduce, not merely one with attractive indentation. Review the transformed output against the original before using it in another system.

Source / further reading: developer.mozilla.org ↗
Editorial note: This guide was prepared with AI assistance and reviewed for its examples and tool behavior during development. It does not claim independent professional accreditation or firsthand product testing beyond the included tools.