JSON Workbench
Parse a JSON value in the browser, then produce readable or compact JSON with separate actions and a visible parser message when the input is invalid.
How it works
Try it in your browser.
Paste a JSON value into the input and choose Format JSON or Minify JSON. Valid input is parsed and serialized into the result panel. When parsing fails, the source stays available for editing and the tool reports the browser parser’s message.
- Choose Format JSON to serialize a valid value with two spaces of indentation.
- Choose Minify JSON to remove optional whitespace from a valid value.
- Use Clear to remove the current input, result, and status message from the page.
How It Works
The workbench calls the browser’s built-in JSON parser on the complete input. Standard JSON values include objects, arrays, strings, numbers, booleans, and null. The parser rejects JavaScript-only syntax such as comments, single-quoted strings, trailing commas, and unquoted property names because those are not JSON.
If parsing succeeds, the tool serializes the resulting value again. The readable action uses two spaces per indentation level; the compact action asks the serializer to omit optional spacing. Both outputs represent the parsed data, rather than preserving the original line breaks, number spelling, or spacing choices.
Serialization can normalize details that were present in the source. For example, insignificant whitespace is removed, escape sequences may be emitted in a different form, and object-key order follows JavaScript’s property-order rules. A repeated object key is not preserved as two independent fields after parsing; the browser value contains the property selected by its parser behavior.
A parse error clears the result so an older valid output cannot be mistaken for the latest attempt. The source text remains in the editor, and the status reports the parser detail returned by the browser. Exact error wording can vary between browser engines, so use the location and message as a clue rather than a portable diagnostic format.
All parsing and serialization happen in the page. There is no file upload, account, remote validator, or automatic save. Very large values still consume memory and run on the main thread, so a huge document may make the tab feel unresponsive even though it never leaves the browser.
Worked Example
A small object has the right JSON meaning but no spaces or line breaks, and you want a version that is easier to review.
{"label":"North","active":true,"count":3}- Choose Format JSON. The parser creates an object with a string, a boolean, and a number.
- The serializer writes those fields over several lines and indents each property by two spaces.
- Choose Minify JSON to generate a compact representation of the same parsed object.
Result: The two outputs describe the same JSON value. If you replace the input with a trailing comma or a comment, parsing fails and the result area is cleared instead of showing stale output.
Common Pitfalls / FAQ
Common pitfalls
- JSON is stricter than JavaScript object-literal syntax. A browser console may accept a form that this parser correctly rejects as JSON.
- Formatting and minifying do not prove that a document follows an application-specific schema. A syntactically valid value can still have missing fields or the wrong types for another program.
- Re-serialization can change whitespace, escape spelling, and ordering details. Keep an untouched copy when byte-for-byte preservation or a digital signature matters.
- Parser message text is supplied by the browser engine and can change. Do not build automated tooling around the exact wording shown here.
Frequently asked questions
Can the workbench check a JSON schema?
No. It checks whether the input can be parsed as JSON and then formats the resulting value. Schema validation requires a separate, known schema and is outside this tool’s behavior.
Can I use comments or a trailing comma?
No. Those are common in some JavaScript configurations but are not part of standard JSON syntax. Remove them before formatting, or use a parser specifically designed for the extended format you have.
Is my input stored when I leave?
The module keeps its working value in page state only. It does not save to local storage or send the JSON to a service. Clear the editor when you are finished if you want the visible value removed before closing the tab.