Start a project

Tool 65 of 100 · API

GraphQL Formatter & Analyser

Paste a GraphQL query or schema and get it neatly formatted or minified, with syntax errors pointed out and a check on how deep and heavy the query is.

GraphQL Formatter & Analyser at a glanceIllustration: 1, A GraphQL query; 2, processed in your browser; 3, Formatted + checked.GraphQL Formatter & Analyser</>1A GraphQL query3Formatted + checked2In yourbrowser
1 A GraphQL query 2 processed on your device 3 Formatted + checked

GraphQL Formatter & Analyser

GraphQL

    Formatted

    Formatted GraphQL

    01

    What it does

    Formats or minifies GraphQL queries and SDL, reports syntax errors by line and checks depth, field count and unused parts.

    • Queries, mutations, subscriptions, fragments and SDL
    • Pretty-print or minify
    • Syntax errors with line and column
    • Query depth and field counts

    02

    Private by design

    Everything happens in your browser. Nothing you type, paste or upload is sent anywhere, and it keeps working offline once the page has loaded.

    03

    What you get

    Formatted or minified GraphQL, with a Copy and a Download button on every result.

    • GraphQL
    • API
    • Formatter

    Why it matters

    GraphQL queries copied from logs and network panels arrive minified, and long queries with nested fragments are hard to review. Deep or very wide queries are also a common cause of slow APIs, and servers often reject them with a depth limit.

    This tool parses GraphQL with a lexer and parser written for this site, prints it cleanly and reports depth, field count and unused fragments or variables, so you can see whether a query is likely to hit your server's limits before you send it.

    How it works

    1. InputA query, mutation, fragments or schema
    2. In your browserParsed and checked for unused and missing parts
    3. OutputFormatted or minified GraphQL with depth

    Where it fits in a designer's workflow

    1. Plan
    2. Design
    3. Build
    4. Test
    5. Launch
    Reviewing queries before they reach the server.

    By the numbers

    The sample query as pasted, formatted and minifiedAs pasted: 325 bytes; Formatted: 501 bytes; Minified: 277 bytesAs pasted325 bytesFormatted501 bytesMinified277 bytes
    Measured by this tool's own parser: 17 fields, 2 fragments and 7 levels deep, with 3 issues found (an undeclared variable, an unused one and an unused fragment). Depth is what servers limit to stop expensive queries. Source: GraphQL spec.
    Show the numbers as a table
    VersionBytes
    As pasted325
    Formatted501
    Minified277

    How to use it

    1. Paste a query, mutation or schema.
    2. Choose format or minify and the indent.
    3. Fix any syntax error at the line shown.
    4. Check the depth and complexity notes, then copy the result.

    FAQ

    Does it check my query against a schema?

    No. It checks the syntax and structure. Field names are only validated by your server's schema.

    What depth is too deep?

    Many servers limit depth to between 7 and 15. Beyond that, a query is likely to be slow or rejected.

    Can I format schema files?

    Yes. Type definitions, enums, inputs, interfaces, unions, directives and descriptions are all formatted.

    Is the query sent anywhere?

    No. It's parsed in your browser.

    Work with me

    Want a site that gets these right?

    I build fast, accessible websites and web apps that pass these checks from day one. Tell me about your project and I'll reply personally with honest next steps.

    All developer tools · Back to leej.uk