# JSON整形ツール

> JSONをオンラインで整形・構文チェック・圧縮。エラーは行と列で表示し、末尾のカンマやシングルクォートはワンクリックで修正。大きな数値とキーの順序もそのまま保持します。

URL: https://acrafto.com/ja/json-formatter-validator/  
Updated: 2026-10-03

Tools are interactive browser apps; there is no public API, no endpoints to call and no server-side processing. To use a tool, open its HTML page in a browser.

上の入力欄にJSONを貼り付けると、このJSON整形・構文チェックツールが入力と同時に内容を検証します。正しいJSONは選んだインデントで見やすく整形するか、1行に圧縮できます。誤りがあれば、行と列、問題箇所をハイライトした抜粋、そしてよくあるミスならワンクリックの修正ボタンが表示されます。処理はすべてブラウザ内で行われるため、APIレスポンスや設定ファイル、エクスポートしたデータがお使いのコンピューターの外に送られることはありません。

## JSON整形ツールでできること

- **JSONの整形**：スペース2つ、スペース4つ、またはタブでインデントします。「キーをソート」にチェックを入れない限り、元のキーの順序はそのまま保たれます。
- **JSONの圧縮（minify）**：スペースと改行をすべて取り除きます。結果の下のサイズ表示で、何バイト減ったかを確認できます。
- **JSONの構文チェック**：現行のJSON標準である[RFC 8259](https://datatracker.ietf.org/doc/html/rfc8259)に照らしてリアルタイムで検証します。ドキュメントが正しくなった時点で、ステータス行が緑色に変わります。
- **よくあるエラーの自動修正**：末尾のカンマ、シングルクォート、引用符のないキー、コメント、Python風の`True`、`None`、`NaN`、`.5`や`+1`のような数値を直します。
- **ファイルの読み込み**：「ファイルを開く」ボタンを使うか、入力欄に`.json`ファイルをドロップします。結果はダウンロードすることも、入力欄に戻してもう一度処理することもできます。

## エラーメッセージが赤い表示より大切な理由

多くのオンラインバリデーターは、どこかが間違っていることしか教えてくれません。ブラウザも大差はなく、Chromeの`JSON.parse`は`Unexpected token } in JSON at position 148`、Firefoxは`expected property name or '}'`と表示するだけで、どちらも何行目を見ればよいかは示しません。このツールは独自のパーサーを持ち、すべてのトークンの開始位置を記録しています。解析が止まると、行と列、その行の抜粋と問題の文字を指すキャレット（^）、そして「2つのプロパティの間のカンマが抜けている可能性があります」のような分かりやすいヒントが表示されます。「エラー箇所へ移動」ボタンを押すと、入力欄のその位置へカーソルが直接移動します。

貼り付けられたドキュメントで特によく見かけるミスは次のとおりです。

| 入力 | 問題 | 正しいJSON |
| --- | --- | --- |
| `{'name': 'Ada'}` | シングルクォート | `{"name": "Ada"}` |
| `{name: "Ada"}` | 引用符のないキー | `{"name": "Ada"}` |
| `[1, 2, 3,]` | 末尾のカンマ | `[1, 2, 3]` |
| `{"a": 1 "b": 2}` | カンマの抜け | `{"a": 1, "b": 2}` |
| `{"ok": True}` | Pythonのリテラル | `{"ok": true}` |
| `{"x": 007}` | 先頭のゼロ | `{"x": 7}` または `{"x": "007"}` |
| `// comment` | コメント | JSONでは使用不可 |

「自動で修正」ボタンは、カンマの抜けと先頭のゼロ以外のすべてを直します。修正はあえて控えめにしてあります。間違った位置にカンマを入れるとデータの意味が変わってしまうため、抜けたカンマの位置を推測することはしません。また`007`は数値の7なのか、コードなのかを判断できません。こうした場合は、代わりに正確な位置を表示します。

## 大きな数値やキーの順序など、壊れやすいもの

多くの整形ツールは、`JSON.parse`で読み込んでから`JSON.stringify`で書き出しています。この往復処理は、気づかないうちにデータを壊します。`1234567890123456789`のようなTwitterやSnowflakeのIDは、JavaScriptの数値の上限である2^53を超えるため、`1234567890123456800`になって戻ってきます。`1.0`という値は`1`に、`1e3`は`1000`に変わります。このJSON整形ツールは数値を浮動小数点数に変換しません。すべてのリテラルを書かれたとおりにコピーするので、出力は入力を解釈し直したものではなく、忠実に整形し直したものです。文字列内のエスケープシーケンスも同様で、`"\u00e9"`は`"\u00e9"`のまま残り、`"é"`には変換されません。

キーの順序も保たれます。JSONの仕様ではオブジェクトのメンバーに順序はないとされていますが、設定ファイルやテストフィクスチャ、コードレビューでは、順序が安定しているほうがずっと読みやすくなります。正規化した形にしたい場合、たとえば2つのAPIレスポンスを差分ツールで比較したいときは、「キーをソート」をオンにしてください。どちらのドキュメントも、すべての階層でプロパティがアルファベット順に並びます。

## JSON整形とJSON圧縮の使い分け

整形したJSONは人が読むためのものです。APIレスポンスを確認するとき、`package.json`や`tsconfig.json`、OpenAPIのドキュメントを書くとき、また差分を1行に1つの変更として見たいリポジトリにフィクスチャを保存するときに使います。JavaScriptの世界ではスペース2つが慣例で、Pythonや.NETのプロジェクトではスペース4つがよく使われます。タブにすれば、読む人がそれぞれ好みの幅で表示できます。

圧縮したJSONは機械のためのものです。整形済みのドキュメントでは空白が20〜40%を占めることが多いため、取り除くと、ブラウザに送るペイロード、Redisやデータベースのカラムに保存する値、HTMLに埋め込む`data-*`属性が小さくなります。gzip圧縮をかければその差は一部縮まりますが、それでも圧縮（minify）済みのJSONのほうがgzip後のサイズも小さくなります。結果の下のサイズ表示で、お手元のドキュメントでの正確な差を確認できます。

## ターミナルやエディターでのJSON整形

繰り返し処理するファイルなら、どんなWebサイトよりもコマンドラインツールのほうが速く済みます。`jq . file.json`で整形、`jq -c . file.json`で圧縮ができ、`python -m json.tool file.json`はPythonがインストールされていればどこでも使えます。Visual Studio CodeではShift+Alt+FでJSONを整形でき、`$schema`プロパティを追加するとスキーマに沿った検証も行われます。このページはそれ以外の場面のためのものです。ネットワークタブからコピーしたレスポンス、ログの1行、Wikiに載っている設定の断片、何もインストールできないマシンでの手早いチェックなどに使えます。

このサイトの関連ツールも紹介します。[Base64エンコード・デコードツール](https://acrafto.com/ja/base64-encoder-decoder/)では、Base64urlでエンコードされたJSONであるJWTのペイロード部分をデコードできます。[UNIXタイムスタンプ変換ツール](https://acrafto.com/ja/unix-timestamp-converter/)は、多くのAPIレスポンスに含まれる`createdAt`の数値を読みやすい日時に変換し、[UUIDデコーダー](https://acrafto.com/ja/uuid-decoder-validator/)はデータ内の識別子のバージョンとタイムスタンプを表示します。その他のツールは[開発者向けツール](https://acrafto.com/ja/developers/)にまとめています。

## よくある質問

### JSONはサーバーにアップロードされますか？

いいえ。解析、整形、修正はすべてブラウザ内のJavaScriptで実行されます。ページの読み込みが終われば、ネットワークを切断してもツールは動作し続けます。内容が記録されたり保存されたりすることはありません。

### エディターではコメントが使えるのに、なぜこのバリデーターはエラーにするのですか？

コメントは、JSONの考案者であるDouglas Crockfordが、パーサーへの指示に使われるのを防ぐためにあえて仕様から外したものです。`tsconfig.json`や`.vscode/settings.json`のようなファイルは、厳密にはエディターが対応しているJSONの拡張形式、JSONCです。API、データベース、多くのプログラミング言語の厳格なパーサーはコメントを受け付けません。修正ボタンはコメントを取り除くので、結果はどこでも有効なJSONになります。

### JSON Linesや複数のオブジェクトをまとめて整形できますか？

1つのJSONドキュメントに含められる値は1つだけです。カンマや改行で区切った複数のオブジェクトを貼り付けると、バリデーターは2つ目の値のところで止まります。全体を角括弧で囲んで配列にしてから整形してください。入力が1つのドキュメントのつもりだったのかを判断できないため、修正ボタンはこれを自動では行いません。

### 扱えるサイズに上限はありますか？

決まった上限はありません。数メガバイトのドキュメントでも、ノートパソコンなら1秒もかからずに整形できます。ページの反応を保つため、約400 kBを超えるとシンタックスハイライトはオフになりますが、コピーとダウンロードはそのまま使えます。

### キーをソートするとデータは変わりますか？

いいえ。JSONのオブジェクトは定義上順序を持たないため（[WikipediaのJSONの記事](https://ja.wikipedia.org/wiki/JSON)を参照）、パーサーはソート後のドキュメントと元のドキュメントを同じ値として読み込みます。配列の順序はデータの一部なので、並べ替えることはありません。

### JSONを文字列に埋め込むにはどうエスケープしますか？

まず圧縮し、次にすべてのバックスラッシュとダブルクォートをエスケープします。多くの言語にはそのための手段が用意されています。JavaScriptなら`JSON.stringify(JSON.stringify(obj))`、Pythonなら`json.dumps(json.dumps(obj))`で、JSONテキストを含むJSON文字列が得られます。

## Other languages

- Čeština (cs): [JSON formatter a validátor](https://acrafto.com/cs/json-formatter-validator/) ([Markdown](https://acrafto.com/cs/json-formatter-validator/index.md))
- Slovenčina (sk): [JSON formatter a validátor](https://acrafto.com/sk/json-formatter-validator-online/) ([Markdown](https://acrafto.com/sk/json-formatter-validator-online/index.md))
- English (en): [JSON Formatter and Validator](https://acrafto.com/en/json-formatter-validator/) ([Markdown](https://acrafto.com/en/json-formatter-validator/index.md))
- Deutsch (de): [JSON Formatter & Validator](https://acrafto.com/de/json-formatter-validator/) ([Markdown](https://acrafto.com/de/json-formatter-validator/index.md))
- Français (fr): [JSON Formatter et validateur](https://acrafto.com/fr/formateur-validateur-json/) ([Markdown](https://acrafto.com/fr/formateur-validateur-json/index.md))
- Español (es): [Formateador y validador JSON](https://acrafto.com/es/formateador-validador-json/) ([Markdown](https://acrafto.com/es/formateador-validador-json/index.md))
- Italiano (it): [JSON formatter e validatore](https://acrafto.com/it/json-formatter-validatore-online/) ([Markdown](https://acrafto.com/it/json-formatter-validatore-online/index.md))
- Português (pt): [Formatador e validador JSON](https://acrafto.com/pt/formatador-validador-json/) ([Markdown](https://acrafto.com/pt/formatador-validador-json/index.md))
- Nederlands (nl): [JSON formatter & validator](https://acrafto.com/nl/json-formatter-validator/) ([Markdown](https://acrafto.com/nl/json-formatter-validator/index.md))
- Polski (pl): [JSON Formatter i walidator](https://acrafto.com/pl/json-formatter-i-walidator/) ([Markdown](https://acrafto.com/pl/json-formatter-i-walidator/index.md))
- Română (ro): [JSON formatter și validator](https://acrafto.com/ro/json-formatter-validator/) ([Markdown](https://acrafto.com/ro/json-formatter-validator/index.md))
- Magyar (hu): [JSON formatter és validátor](https://acrafto.com/hu/json-formatter-validator/) ([Markdown](https://acrafto.com/hu/json-formatter-validator/index.md))
- Ελληνικά (el): [JSON formatter και validator](https://acrafto.com/el/json-formatter-validator/) ([Markdown](https://acrafto.com/el/json-formatter-validator/index.md))
- Български (bg): [JSON formatter и валидатор](https://acrafto.com/bg/json-formatter-validator/) ([Markdown](https://acrafto.com/bg/json-formatter-validator/index.md))
- Hrvatski (hr): [JSON formatter i validator](https://acrafto.com/hr/json-formatter-validator-online/) ([Markdown](https://acrafto.com/hr/json-formatter-validator-online/index.md))
- Slovenščina (sl): [JSON formatter in validator](https://acrafto.com/sl/json-formatter-validator/) ([Markdown](https://acrafto.com/sl/json-formatter-validator/index.md))
- Eesti (et): [JSON formatter ja validaator](https://acrafto.com/et/json-formatter-validaator/) ([Markdown](https://acrafto.com/et/json-formatter-validaator/index.md))
- Latviešu (lv): [JSON formatter un validētājs](https://acrafto.com/lv/json-formatter-validetajs/) ([Markdown](https://acrafto.com/lv/json-formatter-validetajs/index.md))
- Lietuvių (lt): [JSON Formatter ir validatorius](https://acrafto.com/lt/json-formatter-validatorius/) ([Markdown](https://acrafto.com/lt/json-formatter-validatorius/index.md))
- Svenska (sv): [JSON formatter och validator](https://acrafto.com/sv/json-formatter-validator/) ([Markdown](https://acrafto.com/sv/json-formatter-validator/index.md))
- Dansk (da): [JSON formatter og validator](https://acrafto.com/da/json-formatter-validator/) ([Markdown](https://acrafto.com/da/json-formatter-validator/index.md))
- Suomi (fi): [JSON formatter ja validaattori](https://acrafto.com/fi/json-formatter-validaattori/) ([Markdown](https://acrafto.com/fi/json-formatter-validaattori/index.md))
- Norsk (no): [JSON formatter og validator](https://acrafto.com/no/json-formatter-validator/) ([Markdown](https://acrafto.com/no/json-formatter-validator/index.md))
- Українська (uk): [JSON Formatter і валідатор](https://acrafto.com/uk/json-formatter-i-validator/) ([Markdown](https://acrafto.com/uk/json-formatter-i-validator/index.md))
- Русский (ru): [JSON formatter и валидатор](https://acrafto.com/ru/json-formatter-validator/) ([Markdown](https://acrafto.com/ru/json-formatter-validator/index.md))
- Српски (sr): [JSON formatter i validator](https://acrafto.com/sr/json-formatter-i-validator/) ([Markdown](https://acrafto.com/sr/json-formatter-i-validator/index.md))
- Македонски (mk): [JSON Formatter & Validator](https://acrafto.com/mk/json-formatter-validator/) ([Markdown](https://acrafto.com/mk/json-formatter-validator/index.md))
- Bosanski (bs): [JSON formatter i validator](https://acrafto.com/bs/json-formatter-validator/) ([Markdown](https://acrafto.com/bs/json-formatter-validator/index.md))
- Shqip (sq): [JSON Formatter dhe validues](https://acrafto.com/sq/json-formatter-validues/) ([Markdown](https://acrafto.com/sq/json-formatter-validues/index.md))
- Türkçe (tr): [JSON formatter ve doğrulayıcı](https://acrafto.com/tr/json-formatter-dogrulayici/) ([Markdown](https://acrafto.com/tr/json-formatter-dogrulayici/index.md))
- 한국어 (ko): [JSON 정렬 및 검사기](https://acrafto.com/ko/json-formatter-validator/) ([Markdown](https://acrafto.com/ko/json-formatter-validator/index.md))
- العربية (ar): [تنسيق JSON والتحقق منه](https://acrafto.com/ar/json-formatter-validator/) ([Markdown](https://acrafto.com/ar/json-formatter-validator/index.md))
- हिन्दी (hi): [JSON Formatter और Validator](https://acrafto.com/hi/json-formatter-validator/) ([Markdown](https://acrafto.com/hi/json-formatter-validator/index.md))
- Bahasa Indonesia (id): [JSON formatter dan validator](https://acrafto.com/id/json-formatter-validator/) ([Markdown](https://acrafto.com/id/json-formatter-validator/index.md))
- Tiếng Việt (vi): [JSON Formatter và Validator](https://acrafto.com/vi/json-formatter-kiem-tra-json/) ([Markdown](https://acrafto.com/vi/json-formatter-kiem-tra-json/index.md))
- ไทย (th): [JSON Formatter & Validator](https://acrafto.com/th/json-formatter-validator/) ([Markdown](https://acrafto.com/th/json-formatter-validator/index.md))
- עברית (he): [JSON Formatter ובדיקת תקינות](https://acrafto.com/he/json-formatter-validator/) ([Markdown](https://acrafto.com/he/json-formatter-validator/index.md))
