Skip to content

JSON Formatter and Validator

Format, validate, beautify, and minify JSON data with a collapsible tree view and line-and-column error detection.

JSON Formatter and Validator tool

Loading...

Example

Input: {"name":"Ada","age":36,"langs":["en","fr"]} then click Format

Result: 9 lines with 2-space indentation: { / "name": "Ada", / "age": 36, / "langs": [ / "en", / "fr" / ] / }

The JSON is parsed and re-serialized with one key or array item per line. Minify does the reverse and Validate only reports "Valid JSON" or the error line and column.

  1. Paste your raw or minified JSON data into the input text area.
  2. Click Format to validate and pretty-print your JSON with 2-space indentation.
  3. Click Show Tree View to explore nested data in an interactive, collapsible tree.
  4. Click Minify for compact output, or Validate to simply check that the JSON is valid.
  5. Review any validation errors, which include the line and column of the problem.
  6. Click the copy button to copy the formatted JSON to your clipboard.

Understanding JSON Formatting and Validation

A JSON formatter takes compact or messy JSON and lays it out with one key or value per line, indented two spaces per level. This one also checks that the JSON is valid. If it is not, you see the line and column where it breaks.

JSON (JavaScript Object Notation) is the text format most web APIs use to send data. It is strict. Keys need double quotes, single quotes are not allowed, and a comma after the last item is an error. A missing comma in a long one-line API response is almost impossible to spot by eye. Paste it here, click Format, and the error message takes you to the spot.

There are four actions. Format pretty-prints the data. Minify strips out every space and line break. Validate only checks the syntax and reports Valid JSON or the error. Show Tree View opens a folding outline of objects and arrays, with an item count on each branch. The top two levels start open, so you can drill into deep data one branch at a time. Line counts and sizes appear for both the input and the output.

Everything runs in your browser, so tokens or customer data in a payload stay on your device. To compare two versions of a response, use the JSON Diff Viewer. If your file has comments, as many config files do, the JSON Minifier can strip them first.

Sources

Frequently Asked Questions

It means the parser met a character it did not expect at that point. Common causes are a comma after the last item, single quotes around strings or keys, keys without quotes, and comments. JSON allows none of these. The message here includes the line and column, so jump there and also check the character just before it, because the real mistake is often one step earlier.
Format rewrites the JSON with 2-space indentation and one item per line. Minify writes it on a single line with no spaces, which is smaller to send or store. Validate changes nothing and only reports Valid JSON or the first error with its line and column. All three parse the JSON first, so invalid input never produces output.
The keys, values and their order stay the same. Two things can look different. Escape codes such as \u00e9 are shown as the real character, and numbers are written in their shortest form, so 1.0 becomes 1 and 1e3 becomes 1000. One real catch: whole numbers above 9,007,199,254,740,991 lose precision, because JavaScript stores every number as a 64-bit float.
Click Show Tree View. Each object and array becomes a branch you can open or close, with its size shown in brackets, such as [12] for an array of 12 items. The top two levels start open and deeper ones start closed. Strings, numbers, booleans and null are shown in different colors, which makes it easy to spot a number that was sent as a string.
No. Comments are not part of the JSON standard, so Format, Minify and Validate all stop with an error when they reach // or /*. Config files such as tsconfig.json often use JSONC, a variant that allows them. Run those files through the JSON Minifier first, which strips comments and trailing commas, then paste the result here to format it.

Related Tools

JSON to CSV Converter

Convert a JSON array of objects to CSV with automatic column headers, and convert CSV back to JSON in the same tool.

Developer Tools

CSV to JSON Converter

Convert CSV data to a JSON array of objects with header mapping and automatic comma, semicolon, or tab detection.

Developer Tools

JavaScript Minifier

Minify JavaScript by removing whitespace, line breaks, and comments for smaller files, without renaming your code.

Developer Tools

JWT Decoder

Decode JSON Web Tokens to inspect header, payload, and signature without needing the secret key.

Developer Tools

JSON Minifier

Minify JSON by removing whitespace and formatting for compact, production-ready output.

Developer Tools

JSON Diff Viewer

Compare two JSON documents with semantic diff highlighting and detailed change detection.

Developer Tools