Pular para o conteúdo principal

Validar JSON

JSON Validator performs strict RFC 8259 syntax validation directly in your browser without transmitting your payload over the network. It pinpoints the precise line and column of syntax errors with a visual caret pointer, plain-English diagnosis, and specific classification for trailing commas, single quotes, unquoted keys, mismatched brackets, BOMs, and word-processor smart quotes.

Só local

A interface desta ferramenta está em inglês.

Awaiting Input — Paste a JSON document or click “Try Example”
JSON Document to Validate
0 B1 lineLn 1, Col 1

O guia abaixo está disponível apenas em inglês.

How does JSON Validator work?

Standard browser JSON.parse() implementations surface notoriously unhelpful error messages, such as "Unexpected token in JSON at position 4812". This raw exception forces developers to manually count byte offsets and guess which quote, comma, or bracket is misplaced.

The ToolsByUs validator implements a dedicated non-recursive lexical scanner and token validator that tracks line numbers, column positions, delimiter nesting stacks, and character lookaheads according to RFC 8259:

  • Zero Raw Exceptions: Exceptions are caught and translated into actionable diagnostic reports with exact caret snippets pointing at the offending character on the exact line and column.
  • Explicit Error Classification: Accurately identifies trailing commas, unquoted object keys, single quote delimiters, missing separating commas, and mismatched brackets (e.g. closing an array with a curly brace).
  • Smart Quotes & BOM Detection: Catches subtle invisible UTF-8 Byte Order Marks (0xFEFF) and curly smart quotes (“, ”) frequently introduced when copying JSON from rich-text editors or word processors.
  • Strict Number Grammar: Rejects IEEE 754 non-finite numbers like NaN, Infinity, and leading zeroes in numbers (such as 012) which violate RFC 8259 Section 6.
  • 10,000 Depth Protection: Employs an iterative finite-state machine that validates deeply nested structures without encountering browser call stack overflow.

The parser works by maintaining a state machine that transitions between BEFORE_KEY, AFTER_KEY, COLON, BEFORE_VALUE, and AFTER_VALUE states while verifying that opening structural brackets ([ and {) match their exact closing counterparts in last-in-first-out order.

Malformed Input Example

{
  'service': "auth",
  "active": true,
}

Example output

Line 2, Column 3:
  'service': "auth",
  ^
Error: Single quotes are not allowed in JSON. Use double quotes (").
Recommendation: Replace single quotes with double quotes.

What options and edge cases does JSON Validator support?

RFC 8259 Error Diagnostics & Classification
ParameterTypeDefaultBehaviour & edge cases
TRAILING_COMMASyntax ErrorForbiddenTrailing comma preceding } or ]. While valid in JavaScript/JSON5, it violates RFC 8259 Section 4.
SINGLE_QUOTESSyntax ErrorForbiddenSingle quotes (') wrapping strings or property keys. JSON requires standard ASCII double quotes (").
UNQUOTED_KEYSyntax ErrorForbiddenObject property identifiers without double quotes (e.g. { name: 'value' }).
MISSING_COMMASyntax ErrorForbiddenConsecutive object key-value pairs or array members without an intervening comma delimiter.
MISMATCHED_BRACKETStructure ErrorForbiddenMismatched container delimiters, such as closing an array with a curly brace ( ] vs } ).
SMART_QUOTESEncoding ErrorDetectedWord-processor typographical quotes (“ ”). Automatically diagnosed with column location and fix.
BOM (Byte Order Mark)Encoding Error0xFEFFLeading UTF-8 byte order mark prohibited by RFC 8259 Section 8.1 in network interchanges.
NAN_INFINITY_REJECTEDNumber GrammarForbiddenNaN, Infinity, and -Infinity are not valid JSON numeric tokens under RFC 8259 Section 6.

Frequently asked questions

Why does valid JavaScript object syntax fail JSON validation?

JSON (RFC 8259) is an interchange format, not a programming language. Features permitted in JavaScript—such as trailing commas, single-quoted strings, unquoted property keys, comments, and NaN values—are explicitly forbidden by the JSON standard to ensure cross-language interoperability between Python, Go, Java, C++, and Rust parsers.

What does the caret pointer indicate?

The caret (^) points directly to the character column where the lexical parser encountered an unexpected character or illegal sequence, helping you locate the exact syntax break even in multi-megabyte payloads.

How does the validator detect smart quotes?

When text is copied from documentation tools, blog posts, or email clients, ASCII double quotes (") are frequently converted into typographical curly quotes (Unicode U+201C and U+201D). The validator explicitly detects these Unicode code points and advises replacing them with standard double quotes.

Why does JSON reject comments?

Douglas Crockford intentionally removed comments from the original JSON specification to prevent parsers from holding processing directives or pragmas, ensuring JSON remained purely a data-interchange format. For configuration files supporting comments, use JSONC.

How are duplicate keys handled under RFC 8259?

RFC 8259 specifies that object keys should be unique. While some native parsers silently overwrite earlier values with later ones, ToolsByUs highlights duplicate keys with diagnostic warnings to prevent subtle data-loss bugs.

Is my validated payload sent to any backend?

No. Parsing, token checking, and validation happen 100% client-side inside your browser. No data ever leaves your computer, guaranteed by our zero-backend architecture.