JavaScript fixed

toFixed() formats a number using a fixed number of decimal places and returns it as a string, rounding as needed. Essential for money and any human-facing figure.

Syntax

num.toFixed(decimals)

Examples

Input Arguments Output
3.14159 2 "3.14"

Gotchas

  • Returns a string, not a number. Wrap in Number() if you need to keep computing.

Try it live

Type your input and see fixed transform it instantly.

fixed()

Type above to see the result…

Want to go further? Chain fixed with other functions, pipe one output into the next and watch your data transform in the visual Playground.

Related functions

© 2026 Heifara Buval