GraphQL formatter

Paste a GraphQL query, mutation, fragment or schema and get it indented the same way every time. Long argument lists are split over lines, short ones stay on one line, and comments and strings are not touched.

Indent

Runs in your browser: nothing you enter is sent anywhere.

How to use it

  1. Paste a query, mutation, subscription, fragment or schema into the left box.
  2. Pick 2 spaces, 4 spaces or a tab.
  3. Copy the result from the right box.

How it formats

The formatter splits the text into tokens (names, numbers, strings, punctuation and comments) and prints them again with one rule set:

  • A selection set { … } or schema body puts each field, spread or value on its own line.
  • Arguments ( … ), lists [ … ] and object values { … } stay on one line if they fit in 80 columns, otherwise each item gets its own line.
  • Definitions are separated by one blank line; a blank line you left between fields is kept.
  • ...Fragment is written without a space, ... on Type with one.

Example

query Q($id: ID!) { user(id: $id) { name, friends { id } } }

becomes

query Q($id: ID!) {
  user(id: $id) {
    name
    friends {
      id
    }
  }
}

Tips

Formatting twice gives the same text, so it is safe to run on every save. If you get a syntax message, count the brackets near the reported line: a missing } is the usual cause.

Frequently asked questions

Does it work for schemas as well as queries?

Yes. Type, interface, input, enum, union, scalar, directive and schema definitions are laid out one field or value per line, and descriptions in quotes or triple quotes stay above the item they describe.

What happens to commas?

Commas are optional whitespace in GraphQL. On one line they are written as ", " between arguments, variables and list items. When a list is split over several lines the commas are dropped, because the line breaks already separate the items.

When does a list of arguments go onto several lines?

When the argument list, variable list, list value or object value would be longer than 80 columns on its line. Selection sets and schema bodies always use one line per item.

Are comments and strings changed?

No. A # comment is kept, and a comment at the end of a line stays at the end of that line. Strings and triple-quoted block strings are copied exactly, including their own indentation.

Does it check that my query is valid?

Only the basics. It reports unclosed brackets and strings and characters that cannot appear in GraphQL, but it does not check field names against a schema or the full grammar.

More in Developer

All tools in this category: Developer ·Updated November 3, 2026

Privacy choices

Google Analytics shows us which tools are used and whether they work. It may set cookies. Your choice is kept in this browser.