SmartQueryTools

Add Moving Average to JSON Files Online

Add a moving average, rolling sum, rolling min, or rolling max column to JSON files directly in your browser. Choose window size, order-by column, and optional partitioning — no upload required.

How to add Moving Average 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. Pick a window function: Moving Average (the default), Rolling Sum, Rolling Min or Rolling Max. The output column name changes to match, for example moving_avg or rolling_sum.
  3. Choose the value column (numeric columns only) and the window size in rows. The default is 3, and the window is the current row plus the rows before it.
  4. Choose an Order by column, usually a date, and optionally a Partition by column so each group gets its own series. Click Add Rolling Column.
  5. Check the preview, then download the file 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 café tracks cups of coffee sold each day. Daily figures jump around with the weather, so the owner wants a 3-day moving average to see the underlying trend.

Input (JSON)

[
  {
    "sale_date": "2026-05-04",
    "weekday": "Mon",
    "cups_sold": 120
  },
  {
    "sale_date": "2026-05-05",
    "weekday": "Tue",
    "cups_sold": 150
  },
  {
    "sale_date": "2026-05-06",
    "weekday": "Wed",
    "cups_sold": 90
  },
  {
    "sale_date": "2026-05-07",
    "weekday": "Thu",
    "cups_sold": 180
  },
  {
    "sale_date": "2026-05-08",
    "weekday": "Fri",
    "cups_sold": 210
  },
  {
    "sale_date": "2026-05-09",
    "weekday": "Sat",
    "cups_sold": 150
  }
]

Settings

  • Window function: Moving Average
  • Value column: cups_sold
  • Window size: 3 rows
  • Order by: sale_date
  • Partition by: (none)
  • Output column name: moving_avg

Result

sale_dateweekdaycups_soldmoving_avg
2026-05-04Mon120120
2026-05-05Tue150135
2026-05-06Wed90120
2026-05-07Thu180140
2026-05-08Fri210160
2026-05-09Sat150180

From Wednesday on, each value averages that day and the two before it: Thursday is (150 + 90 + 180) / 3 = 140. Monday and Tuesday do not have two earlier rows, so they average what is available: 120 alone, then (120 + 150) / 2 = 135. They are not left empty. Wednesday's dip is smoothed to 120, and the upward trend from Thursday is easy to see.

Working with JSON files

Numbers must sit in a top-level key to be offered as the value column. Time series from APIs often nest them, as in {"t": "...", "metrics": {"cpu": 0.42}}, so flatten the file first. Keys that mix numbers and quoted strings load as a JSON-typed column and are not listed either. Objects missing the value key count as blanks and are skipped inside each window. An explicit null, such as "cups": null, is treated the same way.

If you leave Order by at (none), objects are taken in the order they are read, which usually matches the array. That order is not guaranteed. For a safe result, order by a timestamp key, or add a sequence with Add Row Numbers first. Timestamp strings in ISO form with a T separator may load as text. They still order correctly as long as every value uses the same layout and time zone. The rolling value is the last key in each output object.

Frequently Asked Questions

Do I need an Order by key if my JSON array is already sorted?

It is safer to set one. Without it, rows are processed in read order, which usually matches the array but is not guaranteed. Add Row Numbers gives you a key to order by.

Can I use a nested JSON value such as metrics.cpu?

Not directly. Flatten the JSON first so metrics.cpu becomes a top-level key, then choose it as the value column.

How are the first rows handled when the window is not full yet?

They use whatever rows are available. With a window of 7, row 1 averages 1 value, row 2 averages 2, and from row 7 on every value covers 7 rows. No row is left empty for this reason.

Is the window centred or trailing?

Trailing. It covers the current row and the rows before it, up to the window size. Centred windows and exponential moving averages are not offered. Use the SQL Query tool with a custom window frame for those.

What is the difference between the four window functions?

Moving Average gives the mean of the window, Rolling Sum the total, and Rolling Min and Rolling Max the smallest and largest values. All four use the same window size, order and partition settings.

Related Tools

Round Numbers in JSON Files Online

Round numeric columns in JSON files to any number of decimal places directly in your browser. Set precision per column with a simple slider — no upload required.

Add Lag / Lead Column to JSON Files Online

Add a LAG or LEAD column to JSON files to shift any column forward or backward by N rows. See previous day's sales, next value in a sequence, or any time-shifted comparison — runs entirely in your browser.

Truncate Dates in JSON Files Online

Truncate date and timestamp columns in JSON files to a chosen precision — year, quarter, month, week, day, hour, or minute — directly in your browser. Rounds timestamps down to the start of each period. No upload required.

Add Moving Average to CSV Files Online

Add a moving average, rolling sum, rolling min, or rolling max column to CSV files directly in your browser. Choose window size, order-by column, and optional partitioning — no upload required.

Add Moving Average to Excel Files Online

Add a moving average, rolling sum, rolling min, or rolling max column to Excel files directly in your browser. Choose window size, order-by column, and optional partitioning — no upload required.

Add Moving Average to Parquet Files Online

Add a moving average, rolling sum, rolling min, or rolling max column to Parquet files directly in your browser. Choose window size, order-by column, and optional partitioning — no upload required.

JSON Viewer Online

View and inspect JSON files directly in your browser. Browse rows, check column names and data types — no upload required, your data stays on your device.

Convert JSON to Parquet Online

Convert JSON files to Parquet format directly in your browser. No upload required — your data never leaves your device.