SmartQueryTools

Unpivot JSON Files Online

Reshape JSON files from wide to long format directly in your browser. Melt multiple columns into variable/value pairs — no upload required.

How to unpivot JSON files

  1. Drop your file. The first column is ticked as an ID column by default.
  2. Tick every column that identifies a row, such as an ID, a name or a region. ID columns are repeated on every output row.
  3. Leave the columns you want to melt unticked. Each unticked column becomes rows holding its column name and its value.
  4. Name the two new columns. They default to variable and value.
  5. Click Unpivot, check the long-format preview, and download the result.

Your file is processed locally in your browser and is never uploaded. The free limit is 50 MB per file; larger files work if your device has the memory for them.

Worked example

An HR team runs a two-question pulse survey. The export has one row per respondent and one column per question, but the dashboard tool wants one row per answer. One respondent skipped the second question.

Input (JSON)

[
  {
    "respondent_id": 1041,
    "team": "Support",
    "q1_score": 4,
    "q2_score": 5
  },
  {
    "respondent_id": 1042,
    "team": "Sales",
    "q1_score": 2,
    "q2_score": null
  },
  {
    "respondent_id": 1043,
    "team": "Support",
    "q1_score": 5,
    "q2_score": 4
  }
]

Settings

  • ID columns (ticked): respondent_id, team
  • Value columns (unticked): q1_score, q2_score
  • Variable column name: question
  • Value column name: score

Result

respondent_idteamquestionscore
1041Supportq1_score4
1041Supportq2_score5
1042Salesq1_score2
1042Salesq2_scoreNULL
1043Supportq1_score5
1043Supportq2_score4

Each respondent now has one row per question, with the ID columns repeated. Respondent 1042 skipped question 2, and that row is kept with an empty score. So the result has 6 rows, 3 respondents times 2 questions. Filter out empty scores afterwards if you only want answered questions.

Working with JSON files

In a JSON array every key becomes a column, so the tick list shows all keys found across the objects. Objects missing a key have null there, and each null still produces an output row with a null value. For sparse records, where each object sets only a few of many possible fields, filter out the null values afterwards to get a compact list of only the fields that are set.

When the melted keys hold values that cannot share a type, such as strings next to numbers, every value is written as a string. Keys holding nested objects should be ticked as IDs or removed first. The output is a JSON array with one object per value. Each object holds the ID keys first, then the variable key with the old key name, then the value key. Numbers stay JSON numbers in the value key, and the old key names become plain strings.

Frequently Asked Questions

Can I unpivot JSON records whose keys are dates, like {"id": 7, "2026-01": 12, "2026-02": 9}?

Yes. Tick id as the ID column and leave the date keys unticked. Each date key becomes a value in the variable column, paired with its number.

Do JSON records with missing keys still appear after unpivoting?

Yes. A record appears once for each melted key, and a missing or null key gives a row with a null value. Filter out nulls afterwards if you only want the keys that are set.

Are empty values kept?

Yes. Each input row gives one output row for every value column, even when the value is empty (NULL). Filter the value column afterwards if you want only filled values.

Can I unpivot columns of different types?

Yes. Whole numbers and decimals combine into a number column, and dates and timestamps into timestamps. Any other mix, such as numbers and text, is converted to text so the run still works.

How do I go back from long to wide?

Use the Pivot tool. Put the variable column into the column headers and use the value column for the cells.

Related Tools