json formatter
paste json to pretty-print or minify it. errors show the exact line and column.
runs on your device · free · no sign-up
loading tool…
how to json formatter
- paste your json into the box, or press sample to try it out.
- if it is invalid, read the line and column message and press jump to error to land on the problem.
- pick an indent, minify it, or turn on sort keys, then switch between text and tree view.
- type a path such as $.users[*].name to pull out values, then copy or download the result.
json is strict: keys need double quotes, no trailing commas, no comments, and single quotes are not allowed. most errors people hit come from copying javascript objects or config files that allow those. the error box points at the first character the parser could not accept, which is often a little after the real mistake, so check the line above as well.
minified json removes all spaces and line breaks and is the right format for sending over a network or storing in a database field. a typical api response shrinks by 15 to 30 percent when minified, and much less once gzip is applied. use 2 space indentation for files people will read and for diffs, since sorted keys make version control changes easier to review.
the tree view is best for exploring unfamiliar data, such as an api response with a few hundred fields. collapse everything, open only the branch you need, then click a key and the path box fills in so you can extract all matching values at once.
features
- collapsible tree view with expand all and collapse all, click a key to get its path
- invalid json shows the exact line and column with the broken character highlighted
- path query with dot, bracket, wildcard and recursive search
- minify, 2 or 4 space or tab indent, and alphabetical key sorting
- copy or download the formatted result
- handles large documents locally, nothing is uploaded
popular uses
frequently asked questions
how does the json formatter work?
it parses your text with the browser json parser and prints it again with your chosen indentation, so output is always valid json.
what happens with invalid json?
you get the error message with the line and column where parsing failed, so you can fix trailing commas or missing quotes quickly.
is my json sent to a server?
no. formatting runs locally in your browser and your data never leaves your device.
what query syntax does the path box support?
a simple jsonpath-style syntax: $.user.name, dot paths, bracket indexes like items[0] or items[-1], wildcards like items[*].id and users.*.name, quoted keys like ["first name"], and $..key to find a key at any depth. filters and slices are not supported.
can i format very large json files?
yes, up to what your browser memory allows. files of a few megabytes format instantly. the text view handles large output, and the tree view loads children in batches, so big arrays stay responsive. for files over 50 mb use a command line tool like jq.
why did my numbers or key order change?
json numbers are read as javascript doubles, so integers above 9007199254740991 lose precision. key order is kept as written unless you turn on sort keys. duplicate keys keep only the last value.