Development · Web app

nstr

JavaScript utility to stringify numbers without floating-point UI artifacts

Visit nstr.vercel.app ↗

nstr is a lightweight JavaScript library and web demo created by Shu Ding that formats numbers into clean strings. It automatically detects floating-point calculation anomalies, such as repetitive 9s or 0s caused by binary arithmetic, and cleans them up without requiring hardcoded decimal rounding across an entire UI.

What it's for

  • Format dynamically calculated numbers in frontend UIs without seeing values like 0.30000000000000004
  • Display pricing or currency calculations cleanly without manually tweaking toFixed calls
  • Test floating-point string conversions interactively in the browser before coding

Features

  • Automatic detection of consecutive repeating 0s and 9s generated by floating-point math
  • Avoids fixed decimal formatting issues where small numbers become zero
  • Configurable maxDecimals parameter to cap maximum digits (defaults to 10)
  • Configurable threshold parameter to tune pattern detection sensitivity
  • Interactive web playground to compare nstr against native toString, toFixed, and toPrecision

Pricing

Free

Details

Type
Web app
Category
Development
Topic
JavaScript Utilities
Open source
Yes
Platforms
Web, Code library
For
Frontend and JavaScript developers formatting numeric outputs for user interfaces
Tags
javascript, numbers, math, frontend, utility, open source

Why it was saved

  • @shuding, 22 August 2025: Fixes the classic problem of displaying something like $1989.9999999999998 instead of $1990 when rendering computed numbers in a UI.

Related

  • Motion

    Open-source animation library for React, Vue, and vanilla JavaScript

  • Anime.js

    Lightweight, modular JavaScript animation engine for CSS, SVG, and DOM elements

  • coss ui

    Modern UI component library built on top of Base UI

  • GSAP

    High-performance JavaScript animation library for web elements, SVG, and canvas.

  • 2023 JavaScript Rising Stars

    Annual overview of the fastest-growing JavaScript GitHub repositories in 2023.

  • COBE

    Lightweight 5KB WebGL globe with CSS anchor positioning support

Updated