The API answer is one line, 40 KB long, and the config loader refuses it without saying why. Paste the text into this JSON formatter and the status line tells you at once whether it parses. One click on a Format button then shows how the data nests.
The check is the browser's own JSON.parse. Text that passes here passes in JavaScript as well.
Using the JSON formatter, button by button
- The editor opens with a small sample that is already indented. Clear empties it, and Load sample brings the sample back. Replace it with your own text.
- Watch the status line under the editor while you type. It switches between "Valid JSON" and "Invalid JSON" and shows the size. After an error, a red box above the editor quotes the parser message.
- Press Format (2 spaces) or Format (4 spaces) to replace the text with the indented version. If the text is invalid, nothing is replaced and the error box stays.
- Minify writes one line without whitespace, which is handy before you paste a fixture into a
curlcommand or a one-line environment variable. Sort keys (A-Z) orders the keys of every object and indents the result with 2 spaces. - Copy copies the editor text. Download .json saves it as
data.json.
Why 1.0 turns into 1
The tool does not shuffle your text. It parses it into JavaScript values and writes those values out again. That explains most surprises. 1.0 comes back as 1. The integer 12345678901234567890 comes back as 12345678901234567000, because JavaScript numbers are doubles and lose digits above 9007199254740991. Keep very long IDs as strings.
If one object holds the same key twice, the parser keeps the last value. After formatting, the first value is gone. Compare the result with the original before you commit it.
Sorted keys: Zebra before apple
Two versions of a translation file look different, but you suspect that only the key order changed. Sort both, put them into a diff tool, and only the real changes remain. Sorting works at every depth. Arrays keep their order, because the order of items can carry meaning.
The order is by character code, not by dictionary, so "Zebra" comes before "apple". Keys that look like integers, such as "10", are always listed first. JavaScript does this itself, and sorting cannot change it.
Strict means strict, and there is no undo
Only strict JSON is accepted. These are errors, even though JavaScript or JSON5 would take them:
- comments
- a comma after the last item, the most common reason for a red box
- single quotes instead of
", and keys without quotes
You cannot indent with tabs, and the Format buttons overwrite the editor text, so keep a copy of the original. The page sets no size limit, but it parses on the main thread. A file of several tens of megabytes can freeze the tab for a while. Error wording differs between Chrome, Firefox and Safari.
No request leaves when you press Format
Parsing and formatting are JavaScript on the page. Open the Network tab of your developer tools and click any button: nothing is sent. The tool does not write your text to browser storage. Copy uses the clipboard, and Download creates the file on your device. Only the page itself came from the server, once.