GraphQL Formatter & Beautifier
Format, validate, and beautify GraphQL queries and mutations.
About this tool
Paste a minified or tangled document and the formatter parses it into a GraphQL AST, then reprints it with two-space indentation: nested selection sets, arguments, variable definitions and fragments each get their own line. Queries, mutations, subscriptions, fragment definitions and spreads, inline fragments with type conditions, and @include or @skip directives all come back with unchanged meaning — only whitespace moves. Source comments are dropped: the parser treats them as trivia.
Validation is syntax-level. A Valid/Invalid badge updates as you type, and parse failures print their error message below the input — a missing brace, a stray comma, an unexpected token. It does not type-check fields against a schema: an unknown field is fine here and only fails on a real server.
The AST tab prints the parsed document as JSON — useful for codemods or checking exactly how the parser read your query.
How to use this tool
Paste the document
Copy the query from your code, network tab, or server log into the input panel.
Check the badge
Valid means the syntax parsed; any error message is listed under the input.
Copy the result
Open the Formatted tab and copy the indented output, or inspect the AST as JSON.
What the formatter reprints
| Construct | Behavior |
|---|---|
| Operations | query, mutation and subscription names print before their selection sets |
| Variable definitions | $id: ID! declarations stack inside the operation's parentheses |
| Selection sets | every nested field lands on its own indented line |
| Arguments | long argument lists break one per line |
| Fragments | definitions and ...spreads keep their type conditions |
| Directives | @include and @skip survive the reprint |
Indentation is fixed at two spaces; SDL type definitions are not formatted.
Frequently asked questions
Does the formatter validate my query against a schema?
No. Validation here covers GraphQL syntax — brackets, names, argument structure. Schema-aware checks such as unknown fields or wrong argument types need a server or a client with your schema loaded, so a query can pass here and still fail at runtime.
Can I format a schema (SDL) file?
No. The reprinter handles executable documents — queries, mutations, subscriptions and fragments. Type-system definitions like type or scalar blocks have no formatting rules here, so keep SDL in a dedicated tool.
Will it change the meaning of my query?
No. The output is reprinted from the parsed AST, so fields, arguments and structure stay exactly as written; only indentation and line breaks move. Comments are the one loss, since the parser discards them before formatting.
Is my query sent to any server?
No. Parsing, validation and formatting run in your browser, and nothing you paste is transmitted or stored anywhere. Once the page has loaded, it keeps working even without a network connection.
Related guides
Related tools
JSON Formatter
Advanced JSON formatter with validation, analysis, search, multiple format modes, file upload, and comprehensive statistics.
cURL to Code Converter
Convert cURL commands to code snippets in multiple languages. Parse cURL and generate JavaScript, Python, PHP, and more.
Diff Checker
Compare two text blocks and highlight differences side-by-side