number.toFixed(digits) returns a string of the number in fixed-point form with a set count of digits after the decimal. It rounds when needed and pads with zeros when the value is shorter.
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call number.toFixed. Start with this line.
JavaScript
n.toFixed([digits])
Call
What it does
n.toFixed([digits])
Primary signature.
number.toFixed(...)
Call with the arguments your case needs.
Built into JavaScript. Call toFixed(...) on a number (or Number instance) — no import required.
Library declarations
JavaScript
n.toFixed([digits])
Parameters
Parameter
Description
digits
Optional. Places after decimal (0–100; default 0)
Return Value
Return Value
Description
*
Fixed-point string
JavaScript Examples
Example 1 — Round to Decimal Places
Omit digits for zero places, or pass 2 for money-style display.
With parentheses.(-2.34).toFixed(1) formats the negative value → string "-2.3".
Type is string. Correct for display.
Without parentheses.-2.34.toFixed(1) runs toFixed on 2.34, then applies unary -.
Surprise type. That path yields a number-2.3, not a string.
Compatibility
Browser & Runtime Support
Number.prototype.toFixed() is part of core JavaScript (ES3+) and is Baseline Widely available.
✓ Baseline · ES3+
Number.toFixed()
Supported in every browser and Node.js version. No polyfill needed for fixed-decimal formatting.
99%Universal support
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
toFixedExcellent
Bottom line: Safe everywhere. Ideal for display decimals; use a money library when financial rounding rules matter.
Frequently Asked Questions
Number.prototype.toFixed() returns a string of the number in fixed-point notation with a chosen count of digits after the decimal point. Example: (5.56789).toFixed(2) is "5.57".
digits is an optional integer from 0 to 100 for how many places appear after the decimal point. If you omit it, JavaScript treats it as 0. Values outside 0–100 throw a RangeError.
Always a string. That is why (123).toFixed(2) is "123.00" — useful for display and forms, but you must convert again if you need to do more math.
toFixed() keeps a fixed count of decimal places in plain form (except for huge magnitudes). toExponential() always uses scientific notation. toPrecision() controls significant digits and may use either form.
JavaScript numbers are floating-point. Some decimals cannot be stored exactly, so (2.55).toFixed(1) may be "2.5" and very large digit counts can show long binary artifacts. Prefer a money library for financial rounding rules.
It is part of early ECMAScript and is Baseline Widely available — safe in every modern browser and Node.js.