Tools

Home
JSON FormatterSQL FormatterJS ValidatorMinify CSS
Merge PDFCompress PDFImage to PDF
JPG to PNGPNG to WebPCrop Image

GraphQL Query Prettifier & Indenter

Paste messy GraphQL queries to prettify with proper indentation and consistent formatting

Your files never leave your browser
Input0 chars, 0 lines
Output0 chars, 0 lines
Ready·

Paste any messy or minified GraphQL — queries, mutations, subscriptions, fragments, SDL type definitions — and get properly indented, syntax-highlighted output in one click. Pick 2-space, 4-space, or tab indentation, switch between beautify and minify modes, then copy or download the result as a .graphql file. And everything runs in your browser. Nothing gets uploaded.

How It Works

Paste GraphQL
→
Tokenize & Parse
→
Formatted Output

The tool breaks your GraphQL into tokens — keywords, braces, strings, variables, directives — then walks through them and rebuilds the code with correct nesting depth. Each opening brace increases the indent level, each closing brace decreases it. Arguments stay inline when they’re short. The result gets syntax-highlighted so you can spot types, variables, and directives at a glance.

Examples

Messy User Query

Someone pasted a query from a network tab with no formatting at all.

INPUT
query{user(id:"42"){name email posts{title createdAt}}}
OUTPUT
query { user(id: "42") { name email posts { title createdAt } } }

Mutation with Variables and Directives

A real-world mutation that someone squished into two lines during a code review. Directives, input types, the works.

INPUT
mutation CreatePost($input:PostInput!){createPost(input:$input)@auth(requires:ADMIN){id title author{name}publishedAt}}
OUTPUT
mutation CreatePost($input: PostInput!) { createPost(input: $input) @auth(requires: ADMIN) { id title author { name } publishedAt } }

Minifying a Schema Definition

You want to send a type definition over a webhook and need it as compact as possible.

INPUT
type Product { id: ID! name: String! price: Float category: Category }
OUTPUT (Minified)
type Product{id:ID! name:String! price:Float category:Category}

Who Uses This

👨‍💻 Backend Developers

Cleaning up schema definitions before committing to version control.

🎨 Frontend Developers

Formatting queries pulled from browser DevTools or network logs before debugging.

📝 Technical Writers

Making query examples readable for API documentation.

🔍 QA Engineers

Reading and comparing GraphQL payloads from test logs to spot what changed.

Common Mistakes

Pasting JSON instead of GraphQL

The formatter expects GraphQL syntax, not the JSON response body. If you paste {"data":{"user":{...}}}, it won’t parse right. Use a JSON formatter for responses — this tool is for the query itself.

Including the HTTP wrapper

Some people paste the full POST body: {"query":"query { user { name } }"}. Strip the JSON wrapper first. Just paste the GraphQL string inside the "query" field.

Expecting it to validate your schema

This is a formatter, not a linter. It’ll make your code look pretty even if a field name is wrong or a type doesn’t exist. For validation, you need a schema-aware tool connected to your actual GraphQL endpoint.

Technical Details

Frequently Asked Questions

What is a GraphQL formatter?

It’s a tool that takes messy or minified GraphQL code and adds proper indentation, line breaks, and spacing. Think of it like a code prettifier specifically built for GraphQL syntax — queries, mutations, type definitions, all of it. The query logic stays identical; only the whitespace changes.

How do I prettify a GraphQL query online?

Paste your GraphQL into the input box, pick your indent size (2 or 4 spaces, or tabs), and hit Beautify. That’s it. The formatted result shows up instantly with syntax highlighting. You can copy it or download a .graphql file.

Does formatting change how my GraphQL query works?

No. Formatting only touches whitespace — indentation, line breaks, and spacing around braces. Every field name, argument, variable, directive, and alias stays exactly where it should be. Your API will return the same results whether the query is formatted or minified.

Can I minify GraphQL queries to reduce request size?

Yes — click Minify instead of Beautify. It strips all whitespace, comments, and line breaks down to the smallest possible string. On larger queries, this can cut the payload by 40-60%. Handy when you’re sending queries over mobile networks or optimizing API calls.

Is it safe to paste sensitive GraphQL queries here?

Yes. Everything runs in your browser — no data gets sent to a server. Your queries aren’t logged, stored, or transmitted anywhere. You can disconnect from the internet and the formatter still works, because the entire parser is local JavaScript.

Share: