GraphQL Query Prettifier & Indenter
Paste messy GraphQL queries to prettify with proper indentation and consistent formatting
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
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.
query{user(id:"42"){name email posts{title createdAt}}}
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.
mutation CreatePost($input:PostInput!){createPost(input:$input)@auth(requires:ADMIN){id title author{name}publishedAt}}
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.
type Product {
id: ID!
name: String!
price: Float
category: Category
}
type Product{id:ID! name:String! price:Float category:Category}
Who Uses This
Cleaning up schema definitions before committing to version control.
Formatting queries pulled from browser DevTools or network logs before debugging.
Making query examples readable for API documentation.
Reading and comparing GraphQL payloads from test logs to spot what changed.
Common Mistakes
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.
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.
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
- Processing: 100% client-side — JavaScript tokenizer and formatter
- Browser Support: Chrome, Firefox, Safari, Edge
- Supported Syntax: Queries, mutations, subscriptions, fragments, SDL (type, input, enum, union, interface, schema, directive)
- Output Options: Beautify (2/4 spaces or tabs) and Minify
- Syntax Highlighting: Keywords, types, strings, variables, directives, comments
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.