A GraphQL formatter restructures GraphQL queries, mutations, subscriptions, and schema definitions with consistent indentation and field alignment. Well-formatted GraphQL is easier to read in code reviews, debug in API explorers, and maintain in large schema files.
Formatted GraphQL will appear here...
GraphQL Examples
How to Use the GraphQL Formatter
GraphQL queries from HTTP logs, minified API responses, or multi-line schema files can quickly become unreadable. A GraphQL formatter restores proper indentation for nested field selections, formats arguments consistently, and strips unnecessary whitespace — making queries easier to debug, review, and maintain.
Step 1: Paste Your GraphQL
Copy any GraphQL content — a query, mutation, subscription, fragment definition, or schema type definition — and paste it into the input area. The formatter accepts all standard GraphQL SDL constructs including type, input, enum, interface, union, and directives.
Step 2: Format or Minify
Click Format GraphQL to apply consistent indentation with each field on its own line. Short argument lists stay inline; long ones break onto separate lines. Click Minify to collapse the query into a single line suitable for HTTP transport.
Step 3: Copy or Download
The formatted output appears with syntax highlighting on the right. Click Copy to place it on your clipboard, or Download to save as a .graphql file.
GraphQL Formatting Best Practices
Standard GraphQL conventions: each field selection on its own line, arguments on the same line if they fit (under 60 characters), arguments expanded one-per-line for complex inputs, fragment spreads indented at the same level as fields, and comments (#) on their own line. Schema definitions use the same indentation rules — each field in a type or input on its own line with its type annotation.
FAQ
Is the GraphQL formatter free?
Yes, completely free with no signup required. Format unlimited GraphQL queries and schemas in your browser.
Is my GraphQL code safe?
Yes. All formatting runs locally in your browser. Your queries and schemas are never sent to any server.
What GraphQL constructs does the formatter support?
The formatter handles queries, mutations, subscriptions, fragment definitions, inline fragments, schema type definitions (type, input, enum, interface, union, scalar), directives (@deprecated, @auth, custom directives), and arguments.
What is GraphQL?
GraphQL is a query language for APIs developed by Facebook. Unlike REST, clients request exactly the fields they need. Queries describe the shape of the data, and the server returns exactly that shape. It's used with React, Vue, mobile apps, and many backend services.
Can I minify GraphQL queries?
Yes. The Minify button strips comments and collapses the query into a single line, which reduces payload size when sending queries over HTTP.
How are long argument lists formatted?
Short argument lists (under 60 characters) stay on the same line as the field. Longer argument lists are broken onto separate lines with proper indentation.
Does the formatter support GraphQL schema definitions?
Yes. Schema type definitions (type Query, type User, input CreateUserInput, enum Status, etc.) are formatted with each field on its own line and proper indentation for nested types.