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.

Description: Formats a number to a fixed number of decimal places.

Example: 3.14159 fixed to 2 decimals => 3.14

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

Related functions

© 2026 Heifara Buval