Skip to content

JSON and CSV Formatter: sizes just under 1 MB show as "1024.0 KB" #422

Closed

Description

@prakashNalla

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

  1. prakashNalla commented on Oct 29, 2026

    @prakashNalla
    CollaboratorAuthor

    @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.

  2. added
    bugSomething isn't working
    hacktoberfestGood pick for Hacktoberfest contributors
    on Oct 30, 2026
  3. anurag629 commented on Oct 30, 2026

    @anurag629
    Member

    Confirmed too, both StatsBar copies round the same way. Moving them to the shared formatBytes sounds good. It's yours once #421 or codercops/discord-bot#109 is merged, just say so here.

  4. prakashNalla commented on Oct 30, 2026

    @prakashNalla
    CollaboratorAuthor

    @anurag629 #423 and codercops/discord-bot#110 are both merged, so I'm free for this one.

  5. anurag629 commented on Oct 30, 2026

    @anurag629
    Member

    Hey @prakashNalla, it's yours!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinghacktoberfestGood pick for Hacktoberfest contributors

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions