A lightweight GraphQL code formatter that preserves structural indentation and layout. Current stable version is 1.0.3, with infrequent releases. It focuses on simple, predictable formatting of GraphQL schema definitions, queries, and fragments without heavy configuration or AST manipulation. Ships TypeScript type definitions. Differentiates from alternatives like prettier by being minimal, dependency-free, and respecting existing structural patterns.
npm install graphql-formatterNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage: importing format, passing a multi-line GraphQL string, and logging the formatted output.
Use prettier with graphql plugin if consistent indentation across files is critical.
Validate your GraphQL with a parser before formatting.
Use `import { format } from 'graphql-formatter'` instead of default import.Use `const { format } = require('graphql-formatter')` or enable ESM support.Change to named import: `import { format } from 'graphql-formatter'`Run `npm install graphql-formatter` and ensure tsconfig.json includes types.
No dependency data recorded yet.