Get Top N Rows from NDJSON Files Online
Extract the top N rows per group from NDJSON files directly in your browser. Get the top 5 products per category, highest scores per team, or any ranked subset — no upload required.
How to get Top N Rows from NDJSON files
- Drop your file onto the upload area. The first 200 rows are shown and the first numeric column is pre-selected as the ranking column.
- Choose Rank by column and a Direction: Highest first for the largest values, Lowest first for the smallest.
- Optionally choose a Group by column to get the top rows within each group. Leave it on (none) to rank the whole table.
- Set Top N (default 5). Tick Include rank position column if you want a rank_in_group column showing 1, 2, 3 within each group.
- Click Get Top N, check the row count and preview, then download the result in the same format.
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 race organiser has marathon finish times and wants the two fastest runners in each age group for the podium list.
Input (NDJSON)
{"runner":"Aroha Ngata","age_group":"F40-49","finish_minutes":212.5}
{"runner":"Megan Doyle","age_group":"F40-49","finish_minutes":198.25}
{"runner":"Lena Fischer","age_group":"F40-49","finish_minutes":205}
{"runner":"Tom Reid","age_group":"M50-59","finish_minutes":187.75}
{"runner":"Raj Patel","age_group":"M50-59","finish_minutes":201}
{"runner":"Owen Clarke","age_group":"M50-59","finish_minutes":179.5}Settings
- Rank by column: finish_minutes
- Direction: Lowest first
- Group by: age_group
- Top N: 2
- Include rank position column: on
Result
| runner | age_group | finish_minutes | rank_in_group |
|---|---|---|---|
| Megan Doyle | F40-49 | 198.25 | 1 |
| Lena Fischer | F40-49 | 205 | 2 |
| Owen Clarke | M50-59 | 179.5 | 1 |
| Tom Reid | M50-59 | 187.75 | 2 |
Lower times are better, so Lowest first is used. Each age group is ranked on its own, and the slowest runner in each group drops out. The output is sorted by age_group and then by finish_minutes. The rank_in_group column is added at the end only because the rank option was ticked. With Group by left on (none), the result would be the two fastest runners overall: Owen Clarke and Tom Reid.
Frequently Asked Questions
What happens when two rows tie at the Nth position?
The tool uses ROW_NUMBER, so exactly N rows are returned per group and one of the tied rows is dropped. Which one is not guaranteed. If ties matter, use the Rank tool, which supports RANK and DENSE_RANK, and then filter.
Can I rank by a text or date column?
Yes. Rank by lists every column. Text ranks alphabetically and dates rank chronologically. The first numeric column is only the default.
Where are NULL values placed in the ranking?
After all non-NULL values, whichever direction you choose. They only appear in the result when a group has fewer than N rows with a value.
Related Tools
Sort CSV Files Online
Sort CSV files by any column, ascending or descending, directly in your browser.
Rank Rows in CSV Files Online
Add a rank column to CSV files based on any column's values. Choose RANK, DENSE RANK, or ROW NUMBER, with optional partitioning — runs entirely in your browser.
Aggregate CSV Files Online
Group and aggregate CSV files by any column directly in your browser. Calculate sum, average, min, max, and count for any numeric column — no upload required.
Get Top N Rows from CSV Files Online
Extract the top N rows per group from CSV files directly in your browser. Get the top 5 products per category, highest scores per team, or any ranked subset — no upload required.
Get Top N Rows from Excel Files Online
Extract the top N rows per group from Excel files directly in your browser. Get the top 5 products per category, highest scores per team, or any ranked subset — no upload required.
Get Top N Rows from Parquet Files Online
Extract the top N rows per group from Parquet files directly in your browser. Get the top 5 products per category, highest scores per team, or any ranked subset — no upload required.
Get Top N Rows from JSON Files Online
Extract the top N rows per group from JSON files directly in your browser. Get the top 5 products per category, highest scores per team, or any ranked subset — no upload required.
NDJSON Viewer Online
View and inspect NDJSON files directly in your browser. Browse rows, check column names and data types — no upload required, your data stays on your device.