ExcelをJSONに変換する方法
- 選ぶ
- JSONにする
- コピーする
Excelの表を、プログラムやWebサービスで使うために、JSONにしたい。ExcelをCSV・JSONに変換する の形式で「JSON」を選べば、1行目が項目名になったJSONに変換できます。
手順
- 「.xlsx のExcelファイルを1つ選びます」で、ファイルを選びます。
- 「シート」を選びます。
- 「形式」で、「JSON」を選びます。
- 「変換後」に、JSONが表示されます。
- 「結果をコピー」か「ファイルで保存」で使います。
変換の例
Excelの表:
名前 | 年齢
山田 | 30
佐藤 | 25
JSON:項目名「名前」「年齢」を持つデータが、2件並んだ形になります。
向いているExcelの形
- 1行目に、見出しがある
- 2行目以降に、データが並ぶ
- 空白の行や、結合セルが少ない
変換前に整えるコツ
- 見出しの上のタイトル行は、削除する
- 結合セルは、解除する
- 見出しは、重複しない名前にする
- 不要な列や行は、削除する
変換後のJSONを整える
できたJSONは、JSON整形ツールで整えると、見やすくなり、書き方のチェックもできます。
向いている場面
- Excelのデータを、Webアプリのデータにする
- APIに送るデータの、テスト用に作る
- 設定データを、Excelで管理して、JSONにする
例
商品リストをExcelで管理していた。JSONに変換して、Webサイトの商品一覧データとして使った。
つまずきやすい点
- 項目名が、予想外になる:1行目の内容が、項目名になる。
- 空のセル:空の値として扱われる。
- 日付が数字になる:別の解説を参照。
よくある質問
数値は、数値として出力されますか?
はい。数値のセルは、数値として出力されます。
まとめ
形式で「JSON」を選ぶだけ。1行目が項目名になるので、見出しのある表で使いましょう。
ExcelをCSV・JSONに変換するを使う(無料)あわせて使えるツール
- CSVをExcelファイルにする:CSVを、Excelで開ける .xlsx ファイルにします。
- CSVとJSONを相互変換する:CSVとJSONを、すぐに相互変換します。
- Wordから文字を取り出す:Wordファイルの本文を、文字だけで取り出します。
同じツールの、ほかの解説
How to Convert Excel to JSON
- Choose
- Pick JSON
- Copy
You want to turn an Excel table into JSON for use in programs and web services. Choosing "JSON" as the format in Convert Excel to CSV or JSON converts it to JSON with the first row as item names.
Steps
- With "Choose one .xlsx Excel file", choose the file.
- Choose the "Sheet".
- Under "Format", choose "JSON".
- The JSON appears under "After conversion".
- Use it with "Copy result" or "Save as file".
Conversion example
Excel table:
name | age
Yamada | 30
Sato | 25
JSON: two records, each with the items "name" and "age", lined up.
Excel shapes that suit
- Headings in the first row
- Data lined up from the second row
- Few blank rows and merged cells
Tips for tidying before converting
- Delete title rows above the headings
- Unmerge merged cells
- Give headings unique names
- Delete unneeded columns and rows
Tidying the JSON afterwards
Formatting the JSON with the JSON formatting tool makes it readable and also checks its syntax.
Good for
- Turning Excel data into web app data
- Making test data to send to an API
- Managing configuration data in Excel and making it JSON
Example
Managed a product list in Excel. Converted it to JSON and used it as the product list data for a website.
Common stumbling blocks
- Item names are unexpected: the content of the first row becomes the item names.
- Empty cells: treated as empty values.
- Dates become numbers: see the separate guide.
Frequently asked questions
Are numbers output as numbers?
Yes. Numeric cells are output as numbers.
Summary
Just choose "JSON" as the format. The first row becomes item names, so use it with tables that have headings.
Use "Convert Excel to CSV or JSON" (free)Tools that go well with this
- Convert CSV to Excel (.xlsx): Convert a CSV to an Excel (.xlsx) file.
- Convert CSV and JSON: Convert between CSV and JSON instantly.
- Extract Text from a Word File: Extract the plain text from a Word file.