🧿GraphQL Formatter & Validator - Minify, Lint, to curl
GraphQL copied from logs, network traces or source code is often crammed onto one line or indented every which way. This tool has a lexer and parser written to the GraphQL specification, covering queries, mutations, subscriptions, fragments and inline fragments, variables with defaults, directives and aliases, plus SDL type, interface, enum, union, input, scalar, schema and directive definitions and extend extensions, with descriptions and block strings. Formatting offers 2-space, 4-space or tab indentation and a print width; argument and variable lists that get too long break onto one item per line, and comments stay close to where they were. Minify mode strips comments, commas and extra whitespace for compact request bodies. Syntax errors use graphql-js style messages with the line, column and a caret under the problem. The whole document is analyzed too: every operation and fragment is listed, and you’re warned about variables declared but unused, variables used but not declared (following fragments), unused fragments, unknown fragments, fragment cycles and duplicate names. Pick an operation to build a request containing just it and the fragments it needs, with sample variables filled in from their types, as a POST body JSON, a curl command or fetch() code. Paste SDL and each type is listed with its fields, interfaces, union members, the types it references and the types that reference it, with undefined types flagged. Everything runs in your browser.
Free · No sign-up · Runs in your browserLast updated:
How to use GraphQL Formatter
- 1Paste a GraphQL query or SDL, choose Format or Minify, and set indent, print width and whether to keep comments
- 2Read the highlighted result; if there’s a syntax error, fix it at the reported line and column
- 3Review the outline and checks, build a curl or fetch request for an operation, or browse the SDL type graph
FAQ
- Can formatting change what my query does?
- No. Formatting only changes whitespace, line breaks, indentation and commas; escapes in strings are normalized (\u0041 becomes A) but values stay the same. The parser is tested so that formatted output parses to the same syntax tree and formatting it again changes nothing. Minify rewrites block strings as equivalent regular strings.
- Why is a variable reported as unused when a fragment uses it?
- The check follows every fragment the operation spreads, including nested ones, so variables used inside them count as used. If you still see the warning, that fragment probably isn’t spread by this operation or its name is spelled differently. The spec requires every declared variable to be used, and servers reject operations that break that rule.
- Does it check fields against my schema?
- No. It checks syntax and the document itself — variables, fragments, duplicate names and undefined types — without loading a schema, so it can’t tell whether a field or argument type exists. When you paste SDL, the type graph lists relationships and flags types that are referenced but not defined.
- Can I run the generated curl command as is?
- Replace the endpoint with your GraphQL URL and fill in real variable values, and most servers will accept it; add -H 'Authorization: Bearer …' if authentication is needed. The request contains only the selected operation and the fragments it uses, plus operationName. The tool itself never sends anything.