🌐
JSON Formatter
jsonformatter.org
Best JSON Formatter and JSON Validator: Online JSON Formatter
Online JSON Formatter / Beautifier and JSON Validator will format JSON data, and helps to validate, convert JSON to XML, JSON to CSV. Save and Share JSON
JSON Parser
Online JSON Parser helps to parse, view, analyze JSON data in Tree View. It's a pretty simple and easy way to parse JSON data and share it with others.
JSBeautifier
Online JS Beautifier helps to Beautify Javascript. This Javascript Beautifier helps to unminify, Save and Share Javascript.
XML Formatter
Online XML Formatter will format xml data, helps to validate, and works as XML Converter. Save and Share XML.
Best JSON Pretty Print Online
Best JSON Pretty Print tool to Make Pretty JSON and JSON Print in color and Save and Share Online.
🌐
JSON Formatter
jsonformatter.curiousconcept.com
JSON Formatter & Validator
The JSON Formatter & Validator beautifies and debugs JSON data with advanced formatting and validation algorithms.
🌐
JSON Formatter
jsonformatter.org β€Ί json-pretty-print
Best JSON Pretty Print Online
JSON Pretty Print is very unique tool for prettify json and pretty print JSON data in color.
🌐
JSONLint
jsonlint.com β€Ί json-pretty-print
JSON Pretty Print - Format & Beautify JSON Online | JSONLint | JSONLint
Pretty print JSON instantly with our free online formatter. Customize indentation, sort keys, and beautify minified JSON. No signup required.
🌐
JSON Pretty
json-pretty.com
JSON Pretty β€” simple JSON formatter and editor
JSON Pretty help you to format, edit and pretty print json data. A powerful json formatter, editor and beautify tool for easy data readability.
🌐
Online Tools
onlinetools.com β€Ί json β€Ί prettify-json
Prettify JSON – Online JSON Tools
Free online JSON beautifier. Just load your JSON in the input field and it will automatically get prettified. In the tool options, you can choose whether to use spaces or tabs for indentation and if you're using spaces, you can specify the number ...
🌐
Zerodevx
zerodevx.github.io β€Ί json-pretty-print
JSON Pretty Print Online - Open Source
Convert unformatted JSON into pretty-printed JSON and send the view as a shareable web link.
🌐
Jsonprettyprint
jsonprettyprint.net
βœ… JSON Pretty Print πŸ˜€
JSON Pretty Print 5 stars - "JSON Pretty Print" - Steve Wozniak In all my years as a programmer I worked with a lot of APIs. Whenever I get raw JSON responses from APIs I like to use JSON Pretty Print to format JSON to make it more readable. I've tried a lot of online viewers but this one is the best by a mile because of it's simplicity.
Find elsewhere
🌐
Chrome Web Store
chromewebstore.google.com β€Ί detail β€Ί json-pretty β€Ί nflbalmkceonkkhifbifebanhladdgcp
JSON Pretty - Chrome Web Store
Use JSON Pretty to parse, format, and pretty print json data. A powerful json formatter and beautify tool for easy data readability.
🌐
JSON Editor Online
jsoneditoronline.org
JSON Editor Online: edit JSON, format JSON, query JSON
Format JSON is the same as beautify JSON : you make your JSON file readable by styling it with white spacing, newlines, and indentation. In short: paste your JSON file, then click the "Format" button in code mode, or select "Copy formatted" ...
🌐
Package Control
packagecontrol.io β€Ί packages β€Ί Pretty JSON
Pretty JSON - Packages - Package Control
To prettify JSON, make selection of json (or else it will try to use full view buffer) and through Command Palette Ctrl+Shift+P find β€œPretty JSON: Format JSON” (you can search for part of it like 'pretty format')
🌐
Jsonpretty
jsonpretty.org
JsonPretty - JSON Beautifier and Formatter
Working with JSON data can be a complex task, especially when the code is poorly formatted or difficult to read. JSON Pretty is an invaluable online tool designed to solve this problem by instantly beautifying your JSON data.
🌐
LornaJane
lornajane.net β€Ί posts β€Ί 2024 β€Ί pretty-print-json-with-jq
Pretty-print JSON with jq | LornaJane
jq is a JSON tool, and the "." part is technically a filter – but it includes everything, so it’s more like a not-filter. The output of jq is the same JSON that we put in, but it’s pretty-printed.
🌐
Jam
jam.dev β€Ί utilities β€Ί json-formatter
JSON formatter | Free, Open Source & Ad-free
Beautify and structure raw JSON data with proper indentation and formatting, making it easier to read, edit, and validate JSON content.
Top answer
1 of 16
6935

Pretty-printing is implemented natively in JSON.stringify(). The third argument enables pretty printing and sets the spacing to use:

var str = JSON.stringify(obj, null, 2); // spacing level = 2

If you need syntax highlighting, you might use some regex magic like so:

function syntaxHighlight(json) {
    if (typeof json != 'string') {
         json = JSON.stringify(json, undefined, 2);
    }
    json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
    return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
        var cls = 'number';
        if (/^"/.test(match)) {
            if (/:$/.test(match)) {
                cls = 'key';
            } else {
                cls = 'string';
            }
        } else if (/true|false/.test(match)) {
            cls = 'boolean';
        } else if (/null/.test(match)) {
            cls = 'null';
        }
        return '<span class="' + cls + '">' + match + '</span>';
    });
}

See in action here: jsfiddle

Or a full snippet provided below:

function output(inp) {
    document.body.appendChild(document.createElement('pre')).innerHTML = inp;
}

function syntaxHighlight(json) {
    json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
    return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
        var cls = 'number';
        if (/^"/.test(match)) {
            if (/:$/.test(match)) {
                cls = 'key';
            } else {
                cls = 'string';
            }
        } else if (/true|false/.test(match)) {
            cls = 'boolean';
        } else if (/null/.test(match)) {
            cls = 'null';
        }
        return '<span class="' + cls + '">' + match + '</span>';
    });
}

var obj = {a:1, 'b':'foo', c:[false,'false',null, 'null', {d:{e:1.3e5,f:'1.3e5'}}]};
var str = JSON.stringify(obj, undefined, 4);

output(str);
output(syntaxHighlight(str));
pre {outline: 1px solid #ccc; padding: 5px; margin: 5px; }
.string { color: green; }
.number { color: darkorange; }
.boolean { color: blue; }
.null { color: magenta; }
.key { color: red; }

2 of 16
441

User Pumbaa80's answer is great if you have an object you want pretty printed. If you're starting from a valid JSON string that you want to pretty printed, you need to convert it to an object first:

var jsonString = '{"some":"json"}';
var jsonPretty = JSON.stringify(JSON.parse(jsonString),null,2);  

This builds a JSON object from the string, and then converts it back to a string using JSON stringify's pretty print.

🌐
freeCodeCamp
freecodecamp.org β€Ί news β€Ί how-to-pretty-print-json-in-python
How to Pretty Print JSON in Python
April 14, 2023 - By default, this function produces a JSON string without any formatting, but we can use the indent parameter to specify the number of spaces to use for indentation. Here's an example of how to pretty print JSON in Python:
🌐
Teleport
goteleport.com β€Ί resources β€Ί tools β€Ί json-prettifier
JSON Prettifier | Instantly Format & Beautify JSON | Teleport
JSON Prettify tools automatically add indentation and line breaks, transforming unformatted text into a structured and visually accessible format. This makes the JSON much easier to debug, validate, and share with other developers on your team.
🌐
Js
pretty-print-json.js.org
Pretty-Print JSON β€’ Interactive online JavaScript tool to format ...
Pretty-print JSON data into HTML to indent and colorize (written in functional TypeScript)
🌐
Baeldung
baeldung.com β€Ί home β€Ί json β€Ί jackson β€Ί pretty-print a json in java
Pretty-Print a JSON in Java | Baeldung
July 15, 2023 - Always use the latest versions from the Maven central repository for gson. To pretty-print JSON, we’ll use the setPrettyPrinting() method of GsonBuilder: