GraphQL Formatter
Format and beautify GraphQL queries, mutations, fragments, and schemas with proper indentation and line breaks.
About this tool
Format and beautify GraphQL queries, mutations, fragments, and schema definitions. Paste any GraphQL document and get it back with consistent indentation, proper line breaks, and clean whitespace.
Supports operation definitions (query, mutation, subscription), fragments with spread operator, inline and block string literals, directives such as @skip and @include, type system definitions (type, interface, input, enum, union, scalar), and variable definitions.
For example, a compressed query like {hero{name friends{name}}} is expanded with each field on its own line at the appropriate indentation level. A fragment definition like fragment frag on User {name email posts{title}} gets cleanly separated with proper nesting.
FAQ
Does this work with GraphQL schemas (SDL)? ›
Yes. It handles type, interface, input, enum, union, scalar, extend, and directive definitions. Fields, arguments, implements clauses, and type-level directives are all formatted correctly.
Can I format queries that use variables? ›
Yes. Variable definitions with types and default values inside operation parentheses are formatted properly. Variable references like $var within the query body are preserved.
Does it handle block string literals? ›
Yes. Triple-quoted block strings (""" ... """) are tokenized as single tokens and preserved exactly as written.
Is there a shareable link feature? ›
Yes. Click the Share button to copy a URL with your GraphQL query encoded. Share the link anywhere and the tool will auto-load and format the same query.
Can this format SQL queries? ›
No. This tool formats GraphQL (API queries and schemas). For formatting SQL queries for MySQL, PostgreSQL, SQLite, or Standard SQL with dialect-aware keyword handling, use the dedicated <a href="/sql-formatter">SQL Formatter</a>.