GraphQL Formatter & Schema Viewer

Format or minify GraphQL queries and schemas, see an outline of operations and types, and catch unused variables and missing fragments.

Runs in your browser. Nothing is uploaded.

    How to use the GraphQL Formatter & Schema Viewer

    1. Paste a GraphQL query, mutation, fragment or schema into the left box, open a .graphql file, or press Load example.
    2. The formatted GraphQL appears on the right as you type. Choose Minified (one line) in Output for a compact version.
    3. Check the summary and the list of problems under the boxes, such as unused variables or missing fragments.
    4. Use the outline to see every operation, fragment and type with its variables.
    5. Copy the result or download it as a .graphql file.

    Readable GraphQL in one step

    GraphQL queries tend to arrive in awkward shapes: squashed onto one line in a log, copied from a URL, built by a script, or indented differently by everyone on a team. Deeply nested selections become impossible to read when they are not laid out properly, and a missing brace can hide for a long time.

    Paste a query or schema here and get it back neatly formatted: one field per line, nested selections indented, arguments and variables spaced consistently. Or choose the minified output to squeeze it onto a single line.

    Checks servers would fail

    Besides formatting, the tool checks the document for problems that GraphQL servers reject before they even run a query:

    • Fragments used but not defined, or defined but never used.
    • Variables used but not declared in the operation’s list, or declared and never used.
    • Operations with the same name, or an unnamed operation next to others.

    Each problem shows its line. Syntax errors, such as a missing closing brace, are reported with the line and column.

    Outline of the document

    For long documents and schema files, the outline lists every query, mutation, subscription and fragment with its variables, and every type, input, enum, interface, union, scalar and directive in a schema. It is a quick way to understand what a file contains.

    Works for operations and schemas

    The formatter understands both executable documents (queries, mutations, subscriptions and fragments) and the schema definition language (SDL) used to describe an API. Descriptions in quotes are kept in the formatted output. Comments that start with # are removed, so move notes you want to keep into descriptions.

    Everything runs locally in your browser; your queries and schemas are never sent to a server. For other schema formats, see the Protobuf & Avro Schema Viewer, and format JSON responses with the JSON Formatter.

    Frequently asked questions

    What does the formatter change?

    Only layout. Each field goes on its own line, nested selections are indented by two spaces, and arguments and variables get consistent spacing. Names, arguments and the order of fields stay exactly as you wrote them.

    Does it check my query against a server's schema?

    No, because that would need the schema from your server. It checks the document itself, which catches the mistakes servers reject most often, such as undefined fragments, unused variables and duplicate operation names. Schema files you paste are checked for their own consistency.

    Why minify a query?

    A one-line query is easier to put in a URL, a JSON request body, a curl command or a test fixture. Comments and extra spaces are removed, and the meaning stays the same.

    Can it format schema files (SDL)?

    Yes. Type, input, enum, interface, union, scalar, directive and schema definitions are formatted and listed in the outline, together with descriptions in quotes.

    Is my query uploaded?

    No. Formatting and checks run in your browser.

    Tutorials