Description
Which tool?
JSON Formatter and CSV Formatter
What happened?
The size in the stats bar under both formatters shows 1024.0 KB for inputs from 1048525 to 1048575 bytes, instead of 1.00 MB. Each StatsBar.tsx has its own copy of the size formatter (fmt() in app/(tools)/json-formatter/components/StatsBar.tsx, formatBytes() in app/(tools)/csv-formatter/components/StatsBar.tsx), and both pick KB because the value is under 1024 * 1024, then round it up to 1024.0 with toFixed(1).
This is the same rounding as #421 in the Base64 tool, but in two other copies of the function.
Expected: those sizes show 1.00 MB, the same as 1048576 bytes does.
I'd drop both local copies and import formatBytes from lib/base64-utils.ts (fixed in #421), so there's one formatter with the boundary tests. If you'd rather keep them separate, I can fix each copy in place instead.
Browser and OS
Chrome on macOS
Checks
- I searched existing issues and this is not a duplicate.
- This does not include a real secret or token in the reproduction.
Activity
prakashNalla commentedon Oct 29, 2026
@anurag629 if this is worth fixing, could you assign it to me and add the hacktoberfest label? It's swapping the two local formatters for the shared
formatBytes. I'm holding two issues right now, so I'll start it as soon as one of those frees up.anurag629 commentedon Oct 30, 2026
Confirmed too, both StatsBar copies round the same way. Moving them to the shared
formatBytessounds good. It's yours once #421 or codercops/discord-bot#109 is merged, just say so here.prakashNalla commentedon Oct 30, 2026
@anurag629 #423 and codercops/discord-bot#110 are both merged, so I'm free for this one.
anurag629 commentedon Oct 30, 2026
Hey @prakashNalla, it's yours!