GraphQL Formatter & Minifier
Format and minify GraphQL queries, mutations, and schema definitions. Beautify messy GraphQL for readability or minify it to reduce size. Auto-detects queries vs schemas with built-in syntax validation.
Recommended Settings
GraphQL Formatting Best Practices
- •Prettify GraphQL during development for better readability and debugging
- •Minify queries for production to reduce payload size over the network
- •Use consistent 2-space indentation for query and schema formatting
- •Keep field selections organized with one field per line in prettified format
- •Remove comments and descriptions when minifying for production APIs
Query vs Schema Optimization
- •Queries: Minify before sending to reduce network transfer time
- •Schemas: Keep prettified for documentation and developer understanding
- •Auto-detection identifies content type and handles formatting appropriately
- •Nested fragments and inline fragments are preserved during formatting
- •Directives (@include, @skip, @deprecated) maintain proper syntax
Pro Tips
- •This tool automatically validates GraphQL syntax and reports specific errors
- •Auto-detects whether input is a query/mutation or schema definition
- •Minified GraphQL removes comments and whitespace but preserves functionality
- •Prettified format uses indentation and line breaks for human readability
Most Popular
Prettify for development and code review, minify for production APIs
When to Use This Tool
Format complex queries and mutations for better readability during development. Prettified GraphQL makes it easier to understand query structure, debug issues, and collaborate with team members on API integration.
Minify GraphQL queries before sending them to production APIs to reduce payload size and improve network performance. Smaller queries mean faster transfers and reduced bandwidth costs.
Beautify GraphQL schema definitions for documentation, code reviews, and onboarding new developers. Well-formatted schemas are easier to understand and maintain across large teams.
Prettify messy or minified GraphQL from API logs, network requests, or third-party sources. Clean formatting makes it much easier to identify errors, understand query logic, and test variations.
How It Works
Paste your GraphQL query, mutation, subscription, or schema into the input field
The tool automatically detects whether you have a query or schema definition
Click 'Prettify' to format with proper indentation and line breaks for readability
Or click 'Minify' to remove all whitespace and comments for compact production use
If there's a syntax error, you'll see a specific error message with the problem
Copy the formatted output or download it as a .graphql file
100% Private
Files never leave your device. All processing happens locally in your browser.
Lightning Fast
Powered by Pure JavaScript for optimal performance on modern browsers.
Secure
No data collection, no tracking, no sign-up required.
Frequently Asked Questions
What's the difference between prettify and minify?
Prettify adds indentation, line breaks, and spacing to make GraphQL human-readable. Minify removes all unnecessary whitespace, comments, and line breaks to create the smallest possible query. Both produce valid GraphQL that executes identically.
Does this tool validate GraphQL syntax?
Yes! The tool validates basic GraphQL syntax including balanced braces, parentheses, and brackets. It checks for proper structure and reports specific errors like unmatched braces or invalid syntax. However, it doesn't validate against a specific schema.
Can I format both queries and schema definitions?
Absolutely! The tool auto-detects whether your input is a query/mutation/subscription or a schema definition (types, interfaces, enums, etc.). It handles both formats and applies appropriate formatting rules for each.
Will minifying change my query behavior?
No. Minifying only removes whitespace, comments, and description strings. The actual query structure, field selections, arguments, and directives remain completely unchanged. The server will execute minified and prettified versions identically.
What happens to GraphQL comments when I minify?
Comments (starting with #) and description strings (triple quotes """) are removed during minification to reduce size. If you need to preserve comments or descriptions, use the prettify function instead or keep a formatted backup.
Does this support GraphQL fragments and directives?
Yes! The tool preserves fragments (named and inline), directives (@include, @skip, @deprecated, etc.), and all GraphQL syntax elements. Both formatting operations maintain the complete query structure and functionality.