GraphQL Formatter and Minifier
Paste a GraphQL query, mutation, subscription or schema to format it into clean, indented lines with one selection per line, or minify it down to the smallest valid string. Strings and comments are preserved, and everything runs in your browser.
How to format GraphQL
- Paste your GraphQL query, mutation or schema into the editor.
- Choose Format for readable indentation or Minify to strip whitespace, and pick an indent size.
- Copy the result or download it as a .graphql file.
Examples
Format a query
{user(id:1){name email}}{
user(id: 1) {
name
email
}
}Minify a query
{
user(id: 1) {
name
email
}
}{user(id:1){name email}}Format a schema type
type User{id:ID! name:String email:String}type User {
id: ID!
name: String
email: String
}Frequently asked questions
What does the GraphQL formatter do?
It rewrites a document with consistent indentation and line breaks. Each selection, argument list and schema field is normalized: indentation grows after an opening brace and shrinks before a closing one, every field sits on its own line, and spacing around colons, arguments and directives is tidied. Keywords and field names keep their original casing.
Does it work on queries, mutations and schemas (SDL)?
Yes. It handles queries, mutations and subscriptions, including variables, aliases, fragments, inline fragments and directives, as well as Schema Definition Language such as type, interface, input, enum, union and scalar definitions. List types, non-null markers and default values are formatted cleanly.
What does minify do?
Minify removes every piece of insignificant whitespace and drops standalone comments, keeping a single space only where two tokens would otherwise merge into one. The result is the smallest valid form of your document, which is handy for embedding a query in code or shrinking a request payload.
Are my strings and comments left alone?
String values, including block strings wrapped in triple quotes, are preserved character for character, so words that look like fields are never touched. Comments are kept on their own line when formatting. Minify drops comments because they are not part of execution.
Does it validate or run my GraphQL?
No. The formatter only reshapes whitespace and line breaks. It does not check that your document is valid against a schema, connect to any endpoint, or execute anything. Your GraphQL is restructured exactly as written.
Is my GraphQL private?
Yes. Formatting and minifying happen entirely in your browser. Nothing you paste is uploaded, logged or stored on a server.
Related tools
JSON Formatter
Format, validate and minify JSON online. Pretty-print with custom indentation, sort keys and catch syntax errors. Runs in your browser.
SQL Formatter
Format and beautify SQL online. Put clauses on their own lines, indent the column list and uppercase keywords. Fast and runs in your browser.
HTML Formatter
Beautify and indent messy HTML online. Pretty-print nested tags with custom indentation. Keeps pre, script and style intact. Runs in your browser.
.env to JSON
Convert a .env file to JSON, or JSON back to .env. Parses KEY=value lines, comments, quotes and export. Runs entirely in your browser.
Aspect Ratio Calculator
Calculate aspect ratios fast. Enter a ratio like 16:9 and one dimension to get the other, or enter width and height to simplify the ratio.
Base58 Encoder
Encode and decode Base58 online with the Bitcoin alphabet. Convert text to Base58 or back, UTF-8 safe, no confusing 0 O I l. Runs in your browser.