JSON Validator & Formatter - Validate and Pretty Print JSON | Online Free DevTools by Hexmos

Validate and pretty-print JSON data instantly with JSONLint. Fix syntax errors, format code beautifully, and ensure valid JSON structure. Free online tool.

JSON Validator & Formatter

JSONLint is a powerful command-line utility designed to validate and format JSON (JavaScript Object Notation) data. It helps developers ensure their JSON files are syntactically correct and can also be used to pretty-print JSON for better readability.

Validate JSON Files

The primary function of JSONLint is to validate the structure and syntax of JSON data. This is crucial for preventing errors in applications that rely on JSON for data exchange.

# Validate a JSON file
jsonlint filename.json

Pretty-Print JSON

Beyond validation, JSONLint can also format your JSON data, making it easier to read and understand. This is often referred to as "pretty-printing".

# Pretty-print a JSON file
jsonlint -p filename.json

Using Standard Input

You can pipe JSON data directly into JSONLint from standard input, which is useful when working with other command-line tools.

# Validate JSON from standard input and pretty-print
cat filename.json | jsonlint -p

Displaying Errors with Line Numbers

When validation fails, JSONLint can provide detailed error messages, including line numbers, to help you quickly pinpoint and fix issues.

# Validate JSON and display errors with line numbers
jsonlint -c filename.json

Validating JSON from URLs

JSONLint can also fetch and validate JSON data directly from a given URL.

# Validate JSON from a URL
curl -s http://example.com/data.json | jsonlint

Customizing Indentation

When pretty-printing JSON, you can specify the indentation level to suit your preferences or project standards.

# Validate and pretty-print JSON with specific indent level
jsonlint -p -i 4 filename.json

Suppressing Error Messages

In certain scripting scenarios, you might want to suppress error messages and only rely on the exit code of the command.

# Validate JSON and suppress error messages
jsonlint -q filename.json

Further Resources