GraphQL Formatter
Format GraphQL queries, mutations, fragments and schema definitions with clean indentation, spaced arguments and one field per line.
Processed on your device. Files are not uploaded
How to format GraphQL
Paste your GraphQL
Paste or type it into the box, or press Try an example.
Pick the indentation
Choose 2 or 4 spaces.
Copy or download
Paste the tidy query back into your code.
Worked example
This is what GraphQL Formatter gives for its own sample values. Open the tool above and change anything to try your own.
GraphQL
query Q($id:ID!,$n:Int=5){user(id:$id){...F name friends(first:$n,filter:{a:1}){edges{node{id}}} ... on Admin{perms @include(if:$x)}}} fragment F on User{id email}- Indentation
- 2 spaces
Formatted GraphQL
query Q($id: ID!, $n: Int = 5) {
user(id: $id) {
...F
name
friends(first: $n, filter: { a: 1 }) {
edges {
node {
id
}
}
}
... on Admin {
perms @include(if: $x)
}
...About GraphQL Formatter
Format GraphQL operations, fragments and schema definitions: one field per line, nested selections indented, arguments spaced and comma separated, and a blank line between definitions. Comments and descriptions are kept.
FAQs
Does it work for schemas as well as queries?
Yes. Types, inputs, enums, unions, interfaces and directives are formatted.
Does it check the query against a schema?
No. It only changes layout.
Can I generate types from JSON?
Use JSON to GraphQL Converter.