What is JSON Lint?
A JSON linter is a tool that scans a JSON document for problems — syntax errors that make the JSON unparseable, and (in stricter linters) style issues like inconsistent indentation or duplicate keys. The name comes from the classic lint tool for C, which flagged suspicious code before compilers were smart enough to catch every mistake.
The original JSONLint (jsonlint.com by Zaach Orbach, 2010) popularised the term for JSON. Today, most JSON linters — including this one — focus on syntax because JSON has far fewer style rules than a programming language. If your JSON passes a linter, it will parse cleanly in every conforming JSON parser.
Why Lint JSON?
JSON is the most common data format in modern web APIs, configuration files, and log pipelines. A broken JSON file can crash a service, block a deployment, or corrupt data at scale. Linting catches problems before they cause runtime failures:
- Prevent deploys of malformed
package.json,tsconfig.json, or CI configs. - Validate config files loaded at application startup — a bad config file crashes the whole service.
- Catch webhook payload issues early — invalid JSON often gets logged silently and lost.
- Ensure API responses parse in every consuming client, not just the one you tested with.
How This JSON Linter Works
When you paste JSON and click Format, the tool runs a two-step check:
- Parse— the JSON is passed to the browser's native JSON.parse function. This is the exact same parser used by Chrome, Firefox, Safari, and Node.js. If parsing succeeds, the JSON is well-formed by the RFC 8259 standard.
- Report — on failure, the linter extracts the error message and character position from the SyntaxError object and displays them alongside the input, so you can jump directly to the problem.
Everything happens in your browser. There is no upload, no server processing, no logging. The tool works offline once loaded, and your JSON never leaves your device.
JSON Linting in Your Editor
VS Code
VS Code lints JSON automatically for any file with a .json extension. Errors show as red squiggles in the editor and appear in the Problems panel (Cmd+Shift+M on Mac). Configure schema validation by adding a $schema line or via json.schemas in settings.
WebStorm / IntelliJ
JetBrains IDEs highlight JSON errors as you type. Right-click a JSON file to jump to "Validate JSON" or configure JSON Schema mappings under Settings → Languages & Frameworks → JSON Schema Mappings.
Vim / Neovim
" Install a JSON linter via ALE or coc.nvim
" Or run jq manually:
:%!jq .
" To auto-format on save (with jq installed):
autocmd BufWritePre *.json %!jq .Command-Line JSON Linters
jq (fastest, most common)
# Silently succeed on valid JSON, exit non-zero on invalid
jq empty file.json
# Show errors with position
jq . file.json
# Batch validate all JSON in a directory
find . -name "*.json" -exec jq empty {} \; -o -printjsonlint (npm)
# One-off run without installing
npx jsonlint file.json
# Install globally
npm install -g jsonlint
jsonlint file.json
# Auto-fix indentation issues (does not fix syntax)
jsonlint -i file.jsonPython built-in
# Silently validate
python3 -m json.tool file.json > /dev/null && echo OK || echo INVALID
# With error details
python3 -c "import json,sys; json.load(open(sys.argv[1]))" file.jsonAdding JSON Lint to Your CI Pipeline
Add a pre-commit or CI step to prevent invalid JSON from ever reaching main.
GitHub Actions
- name: Lint all JSON files
run: |
set -e
for f in $(find . -name "*.json" -not -path "./node_modules/*"); do
echo "Linting $f"
jq empty "$f"
donePre-commit hook (husky)
# .husky/pre-commit
git diff --cached --name-only --diff-filter=ACM | grep '\.json$' | while read f; do
jq empty "$f" || { echo "Invalid JSON in $f"; exit 1; }
doneGitLab CI
lint-json:
image: alpine:latest
script:
- apk add --no-cache jq
- find . -name "*.json" -exec jq empty {} \;Duplicate Keys and Other Quality Issues
RFC 8259 technically allows duplicate keys but calls the behaviour "unpredictable". Most parsers keep only the last value, silently discarding the first. This is almost always a bug — a linter should warn about it.
// Valid JSON but a code smell — the "name" property appears twice
{
"name": "Alice",
"age": 30,
"name": "Bob"
}
// JSON.parse returns { name: "Bob", age: 30 }For duplicate-key detection use the json-lint-cli npm package or a stricter parser like secure-json-parse. Some code review tools also flag duplicate keys in JSON automatically.
JSONLint Alternatives Compared
- jsonlint.com — the original web tool. Excellent, but limited to syntax; sends data to their server.
- This tool (PromptSpace JSON Lint) — browser-only, private, includes side-by-side error position and beautification.
- jq CLI — best for scripts and CI; not a browser tool.
- VS Code built-in — best for interactive coding; requires the file to be open in the editor.
- Ajv — best when you also need JSON Schema validation.
Key Facts
- Standard:
- RFC 8259 (strict JSON — no comments, no trailing commas)
- Engine:
- Native JSON.parse — same as Chrome, Firefox, Node.js
- Error info:
- Character position + human-readable explanation
- Privacy:
- Runs entirely in-browser — nothing leaves your device
- Similar to:
- jsonlint.com, jq, VS Code's built-in JSON diagnostics
- Cost:
- Free forever, no signup, no ads on the tool
Related JSON Tools
- Validate JSON Online — same engine, focused on validation workflow
- Fix Invalid JSON — troubleshooting the most common JSON errors
- Format JSON Online — beautify JSON with proper indentation
- JSON Viewer Online — explore JSON structure interactively
- Minify JSON Online — compress JSON for production
- Sort JSON Keys — canonicalise for reproducibility