メインコンテンツへスキップ
Z

GraphQLフォーマッター

公式のgraphql/languageパーサーを使って、GraphQLのquery・mutation・SDLをきれいに整形します。

無料 登録不要 クライアントサイド プライバシーに配慮 Updated

GraphQLパーサーを読み込み中...

使い方

  1. 1 GraphQLのquery、mutation、subscription、またはSDLを貼り付けます。
  2. 2 「整形」を押すと、公式の<code class="rounded bg-slate-100 px-1 text-xs dark:bg-slate-800">graphql/language</code>プリンターで再フォーマットされます。
  3. 3 「圧縮」は空白やコメントを取り除き、より軽量な形に変換します。
  4. 4 構文エラーがある場合は、行番号と列番号とともに表示されます。

このツールを使う理由

  • <code class="rounded bg-slate-100 px-1 text-xs dark:bg-slate-800">graphql/language</code>公式のparse/print関数を使用しているため、出力は標準(canonical)なSDLになります。
  • パーサーは必要になったときだけ読み込まれる仕組みなので、初回入力までは余計な読み込みが発生しません。
  • 整形(リポジトリ保存向け)と圧縮(転送向け)の両方向に対応しています。
  • 処理はすべてクライアント側で完結し、queryがブラウザの外に送信されることはありません。

よくある質問

このツールはGraphQLのSDL(スキーマ)にも対応していますか?

はい。SDL(スキーマ定義言語)も同じ仕組みでパース・整形されます。types、directives、unionsを含むスキーマ全体の整形に利用できます。

なぜ最初の整形だけ少し時間がかかるのですか?

GraphQLのパーサーライブラリは、最初の入力があったタイミングで遅延読み込み(lazy load)されるためです。2回目以降の整形は即座に処理されます。

fragmentsやvariablesの並び順は変わってしまいますか?

いいえ、プリンターは元の宣言順序をそのまま維持します。変わるのは空白やカンマの配置だけです。

GraphQLフォーマッター とは?

GraphQLフォーマッター(GraphQL Formatter)は、公式のgraphql/languageパーサーを使ってGraphQLのquery・mutation・スキーマ定義言語(SDL)をきれいに整形するツールです。入力をパースしたうえで一定のインデントと空白ルールで再構築し、読みやすく構造の整ったGraphQLドキュメントをブラウザ上だけで生成します。

機能

AST-based printing

Parses with graphql-js and re-prints from the AST, so output is always syntactically valid.

Queries, mutations & SDL

Formats operations and type definitions alike, including fragments and directives.

100% private

Your GraphQL is parsed on the device and never uploaded.

Input

{ user(id:1){name posts{title}} }

Output

{
  user(id: 1) {
    name
    posts {
      title
    }
  }
}

主な用途

  1. 1

    Tidy a copied query

    Reformat a one-line or messy GraphQL query into a readable, indented form.

  2. 2

    Clean up SDL

    Normalize a schema file's spacing before committing or reviewing.

  3. 3

    Validate while formatting

    A parse error pinpoints a syntax mistake before you send the query.

概要

Zerethon's GraphQL formatter pretty-prints queries, mutations, and schema definition language (SDL) using the official graphql-js parser. It parses the document into an AST and re-serializes it with consistent two-space indentation and spacing, so malformed input surfaces as a parse error rather than silently reformatting. Everything runs in your browser.

カテゴリ
開発者
料金
無料
プライバシー
ブラウザベース
登録
不要

References

プライバシー

明記されない限り、データがブラウザの外に送信されることはありません。GraphQLフォーマッター は完全にクライアント側で動作します — サーバーへのアップロードなし、ログなし、入力内容のトラッキングなし。

関連ツール

Zerethon Social で作成・共有・成長しよう

無料登録。ポイントを獲得し、実績を集め、世界中のクリエイターとつながりましょう。

Zerethon を無料で試す