GraphQL Query Formatter

Format and prettify GraphQL queries, mutations, subscriptions, and fragments with correct indentation.

API ToolsAPI & Backend
Loading tool...

How to Use GraphQL Query Formatter

How to Use the GraphQL Query Formatter

Step 1: Paste Your Query

Paste any GraphQL operation into the left textarea. This can be a query, mutation, subscription, or fragment definition. Minified one-liners, partially formatted code, and multi-operation documents are all supported.

Step 2: Choose Indent Size

Use the Indent selector in the top-right corner of the input panel to choose between 2 spaces (default) or 4 spaces. This controls how deeply nested fields and selections are indented in the output.

Step 3: Load an Example (optional)

Click one of the example buttons below the textarea to load a pre-built query:

  • Simple Query — a basic query with a field argument
  • With Variables — a query using $variables, a directive (@include), and nested selections
  • Mutation — a mutation with an input variable
  • With Fragments — fragment definitions and spreads across multiple operations
  • Subscription — a subscription operation

Step 4: Click Format Query

Click the Format Query button. The formatted output appears in the right panel with correct indentation and each field on its own line.

Step 5: Copy or Download

Use the Copy button to copy the formatted query to your clipboard, or click .graphql to download the result as a formatted.graphql file.

What the Formatter Does

  • Places each selected field on its own line
  • Indents nested selection sets by the chosen indent size
  • Keeps field arguments (arg: value) inline with the field name
  • Keeps variable definitions ($id: ID!) inline with the operation name
  • Formats fragment spreads (...FragmentName) and inline fragments (... on Type) as separate lines
  • Preserves directives (@include, @deprecated) inline with their field
  • Preserves string literals and comments without modification

Limitations

The formatter is a lightweight token-based prettifier, not a full GraphQL parser. It does not validate the query structure or check types. For full GraphQL spec compliance and error checking, use the GraphQL Schema Validator or an official GraphQL library.

Frequently Asked Questions

Most Viewed Tools

📺

Screen Size Converter

1,621 views

Calculate screen width and height from diagonal size and aspect ratio. Convert between inches and centimeters for displays, TVs, and monitors with instant dimension calculations.

Use Tool →
🔀

Reorder PDF Pages

600 views

Drag and drop to rearrange PDF pages in any order. Upload your PDF, preview all pages as thumbnails, drag pages to reorder them, and download the rearranged PDF. Fast, visual, and privacy-focused.

Use Tool →
🖨️

DPI Calculator

569 views

Calculate DPI (dots per inch), image dimensions, and print sizes. Convert between pixels and physical dimensions for printing and displays.

Use Tool →
📄

Paper Size Converter

512 views

Convert between international paper sizes (A4, Letter, Legal) with dimensions in mm, cm, and inches. Compare ISO A/B series and North American paper standards.

Use Tool →

Fuel Consumption Converter

406 views

Convert between MPG (miles per gallon), L/100km (liters per 100 kilometers), and other fuel efficiency units. Compare car fuel economy across different measurement systems.

Use Tool →
✂️

CSV Splitter

362 views

Split large CSV files into smaller files by number of rows. Process large datasets in manageable chunks instantly.

Use Tool →
🛍️

Product Schema Generator

331 views

Generate JSON-LD Product schema markup for SEO. Add product details like name, price, brand, rating, and availability to create structured data for rich search results.

Use Tool →
📄

Large Text File Viewer

309 views

View and search large text files up to 200MB in your browser. Features virtual scrolling, line numbers, search functionality, and file statistics. Perfect for log files, CSV, JSON, and code files.

Use Tool →

Related API & Backend Tools

Share Your Feedback

Help us improve this tool by sharing your experience

We will only use this to follow up on your feedback