SmartQueryTools

Add Calculated Column to JSON Files Online

Add a new column to JSON files computed from an arithmetic expression over existing columns. No formulas, no code — just point and click.

How to add Calculated Column to JSON files

  1. Drop your file onto the upload area. It is loaded into the in-browser engine and the first 200 rows are shown.
  2. Type a name for the new column. The default is "calculated".
  3. Build the expression. Pick a column or "constant" on the left, choose an operator (+, −, ×, ÷ or %), then pick a column or constant on the right. The two sides start on the first and second columns of the file.
  4. Click Calculate. The new column is added as the last column and the preview updates.
  5. Download the result in the same format you uploaded.

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

A hardware shop exports its stock count and wants the value of stock on the shelf for each product line: units counted multiplied by unit cost. One line was not counted this week.

Input (JSON)

[
  {
    "sku": "HW-101",
    "item": "Wood screws 4x40 (box)",
    "units": 38,
    "unit_cost": 4.25
  },
  {
    "sku": "HW-102",
    "item": "Brass hinge pair",
    "units": 12,
    "unit_cost": 7.5
  },
  {
    "sku": "HW-103",
    "item": "Wall plugs (100)",
    "units": 0,
    "unit_cost": 2.75
  },
  {
    "sku": "HW-104",
    "item": "Masking tape 24mm",
    "units": null,
    "unit_cost": 3.25
  },
  {
    "sku": "HW-105",
    "item": "Sandpaper P120 (10)",
    "units": 25,
    "unit_cost": 5.75
  }
]

Settings

  • New column name: stock_value
  • Expression: units × unit_cost

Result

skuitemunitsunit_coststock_value
HW-101Wood screws 4x40 (box)384.25161.5
HW-102Brass hinge pair127.590
HW-103Wall plugs (100)02.750
HW-104Masking tape 24mmNULL3.25NULL
HW-105Sandpaper P120 (10)255.75143.75

Each row multiplies its own units by its own unit_cost, and the result is appended as stock_value. Wall plugs have a real count of 0, so their value is 0. Masking tape has no count at all, so its value is NULL, not 0: any arithmetic with a NULL operand gives NULL. Run Fill Empty Values first if a blank count should be treated as zero.

Working with JSON files

A JSON array of objects is loaded as a table, one column per key. The engine inspects the values to pick a type. A key that holds numbers in every object becomes a numeric column. A key that mixes numbers with strings, such as 42 in one object and "42" in another, becomes a JSON-typed column and cannot be used in arithmetic until it is cast. Objects that are missing the key get NULL, and so does the calculated value for those objects.

The result is written back as a JSON array with the new key added as the last key of each object. Values are written as JSON numbers. Dividing by zero gives null, so every value in the new key is a number or null. Nested objects are carried through unchanged but cannot be used as operands. Flatten the file first if the value you need lives inside a nested object such as pricing.net.

Frequently Asked Questions

Why does the calculation fail on one of my JSON keys?

Keys that hold nested objects are loaded as struct columns, and keys that mix numbers and strings are loaded as JSON-typed columns. Both appear in the dropdown, but neither works in arithmetic. Flatten nested keys, and make sure numeric keys hold real numbers rather than quoted strings.

Does the calculated JSON output keep my other keys and their order?

Yes. Every original key is kept in its original order, and the new key is added at the end of each object.

Can I use more than two operands or brackets in one expression?

No. Each run applies one operator to two operands, which can be columns or constants. Every run starts from the file you uploaded, so to chain steps, download the result, drop it back in and calculate again. For longer formulas, use the SQL Query tool.

What happens if I divide by zero?

The calculation does not stop. Rows where the divisor is zero get an empty (NULL) result, for both ÷ and %, whatever the column types. Every format writes it the same way, as an empty value.

How does the % operator work?

It is modulo, the remainder after division, not percent. 17 % 5 gives 2, and the sign follows the left operand, so -5 % 3 gives -2. To get a percentage, divide one column by another, then multiply the result by the constant 100 in a second run.

Related Tools