GraphQL Formatter
Format GraphQL schemas and queries with consistent indentation. It runs entirely on your device — nothing is uploaded.
Example
Format GraphQL schemas and queries with consistent indentation.
How it works
Prettier's GraphQL parser re-prints your SDL or queries with a clean, standard layout.
Good to know
The GraphQL Formatter takes raw GraphQL — either schema definitions written in SDL (Schema Definition Language) or operation documents like queries, mutations, subscriptions, and fragments — and re-prints it with consistent indentation, spacing, and line breaks. It uses Prettier's GraphQL parser under the hood, so the output matches the layout most teams already standardize on. It's aimed at backend and frontend developers, API authors, and anyone reviewing or documenting a GraphQL service.
Reach for it when you've pasted a schema from a gateway, copied a query out of network logs or a Postman/Insomnia collection, or merged hand-edited SDL that has drifted into uneven indentation. It's also handy for cleaning up a snippet before dropping it into a pull request, an issue, or documentation, so reviewers see structure rather than formatting noise.
Read the result structurally rather than line by line: fields line up under their type or operation, nested selection sets are indented one level deeper, and arguments and directives sit on predictable lines. If the tool returns an error or refuses to format, that's a signal your input isn't valid GraphQL — a missing brace, an unterminated string, or mixing SDL with an executable operation in the same paste. Fixing the reported syntax is usually faster than reformatting by hand.
A practical caveat: this is a formatter, not a validator or linter. It normalizes layout but does not check your fields against a schema, resolve types, or flag deprecated usage, and it won't reorder fields or strip unused fragments. Everything runs locally in your browser, which makes it safe for proprietary schemas, but pair it with a schema-aware tool if you need correctness guarantees beyond pretty-printing.
Frequently asked questions
Is my data uploaded anywhere?
No — everything runs in your browser. Your code never leaves your device, so it's safe for private work and runs offline once loaded.
Is this tool free?
Yes, completely free with no sign-up and no limits.
People also ask
Does the GraphQL Formatter validate my schema against types?
No. It only re-prints valid GraphQL with consistent formatting. It will surface a syntax error if the input can't be parsed, but it does not check field types, resolve references, or perform schema validation.
Can it format both GraphQL schemas (SDL) and queries?
Yes. The Prettier GraphQL parser handles both schema definition language (types, interfaces, enums, inputs) and executable documents such as queries, mutations, subscriptions, and fragments.
What is GraphQL SDL?
SDL stands for Schema Definition Language, the human-readable syntax used to describe a GraphQL schema's types, fields, arguments, enums, and directives. It is distinct from the query documents clients send to execute operations.
Will the formatter change the meaning of my GraphQL?
No. It only adjusts whitespace, indentation, and line breaks. Field order, selection sets, arguments, and directives are preserved, so the formatted output is semantically identical to the input.
Why does the formatter return an error instead of output?
The most common cause is invalid GraphQL syntax, such as a missing brace or bracket, an unterminated string, or pasting schema SDL and an executable operation together. Correcting the syntax usually resolves it.
What indentation does Prettier use for GraphQL?
Prettier applies a standard, opinionated layout with consistent two-space-style indentation for nested selection sets and fields. It is the same default style widely adopted across GraphQL projects.
Is the GraphQL Formatter safe for private or proprietary schemas?
Yes. The tool runs entirely client-side in your browser, so the GraphQL you paste is processed locally and is not uploaded to any server.
Can I use this offline?
Once the page and its scripts have loaded in your browser, the formatting runs locally and continues to work without an active internet connection.
Related tools