JavaScript Number toExponential() Method

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Scientific form

What You’ll Learn

Number.prototype.toExponential() formats a number as an exponential (scientific) string (same API as MDN Number.toExponential). Optional fractionDigits controls digits after the decimal. This tutorial covers syntax, special values, comparisons, five examples, and try-it labs.

01

Syntax

toExponential(digits)

02

Form

d.dddde±e

03

Digits

0 to 100

04

Default

As needed

05

Parse back

parseFloat

06

Baseline

Everywhere

Introduction

Huge and tiny numbers are hard to read as plain decimals. Scientific notation writes them as a short mantissa times a power of ten — for example 1.23 × 105. In JavaScript that looks like "1.23e+5".

toExponential() builds that string for you. Use it for logs, science UIs, charts, and any place where a consistent exponential layout beats a long digit run.

This page is part of JavaScript Number Methods. Related formatters include toString(), toFixed(), and toPrecision().

Understanding the toExponential() Method

Call number.toExponential() or number.toExponential(fractionDigits) on a number primitive or Number object. You always get a string; the number itself does not change.

The result has one digit before the decimal point (unless the number is zero), then an e+ or e- exponent. Negative numbers keep a leading -.

💡
Beginner Tip

Integer literals need parentheses or a space before the dot: (77).toExponential() or 77 .toExponential(). Otherwise 77.toExponential looks like a decimal to the parser.

📝 Syntax

General form of Number.prototype.toExponential:

JavaScript
number.toExponential()
number.toExponential(fractionDigits)

Parameters

  • fractionDigits (number, optional) — integer from 0 to 100. Digits after the decimal point. If omitted, use as many digits as needed.

Return value

Always a string in exponential notation. Special cases:

ValueReturns (example)
Normal number(77.1234).toExponential()"7.71234e+1"
With digits(77.1234).toExponential(2)"7.71e+1"
Negative number(-6.5e6).toExponential()"-6.5e+6"
Tiny magnitude(0.0000123).toExponential()"1.23e-5"
0 / -0"0e+0" (sign of -0 may appear as "-0e+0")
Infinity"Infinity"
NaN"NaN"

Exceptions

  • RangeErrorfractionDigits < 0 or > 100.
  • TypeError — called on a non-Number this value (for example a plain object).

Common patterns

JavaScript
(77.1234).toExponential();     // "7.71234e+1"
(77.1234).toExponential(2);    // "7.71e+1"
(123456).toExponential(2);     // "1.23e+5"
(-6.5e6).toExponential();      // "-6.5e+6"
Number.parseFloat("123e-2").toExponential(1); // "1.2e+0"

⚡ Quick Reference

GoalCode
Full exponential stringn.toExponential()
2 digits after decimaln.toExponential(2)
Large integer, short form(123456).toExponential(2)
Very small number(1.23e-5).toExponential()
Parse exponential textNumber.parseFloat("1.23e+5")
Fixed decimals (not expo)n.toFixed(2)

🔍 At a Glance

Four facts to remember about Number.prototype.toExponential().

Returns
string

The number is never changed

Digits
0–100

Optional fractionDigits range

Shape

Always scientific notation

Support
Baseline

Works in all modern engines

📋 toExponential() vs toFixed() vs toPrecision()

toExponential(d)toFixed(d)toPrecision(p)
Main jobAlways scientific formFixed decimal placesSignificant digits
Example for 1234.5"1.23e+3" (d=2)"1234.50" (d=2)May be plain or expo
Best forScience / huge & tiny valuesCurrency / UI decimalsControlled precision display

Examples Gallery

Examples follow MDN patterns. Use View Output or Try It Yourself for each case.

📚 Getting Started

Default call, then control fraction digits.

Example 1 — Default Exponential

Omit the argument to keep as many digits as needed.

JavaScript
(77.1234).toExponential();  // "7.71234e+1"
Try It Yourself

How It Works

77.1234 becomes one digit before the point (7), then the rest of the significand, then e+1 because the value is about 7.71 × 101.

Example 2 — Limit Fraction Digits

Pass 2 to round to two digits after the decimal in the mantissa.

JavaScript
(77.1234).toExponential(2);  // "7.71e+1"
Try It Yourself

How It Works

The engine rounds the mantissa to two fractional digits. Try (4) to get "7.7123e+1".

📈 Practical Patterns

Large values, tiny values, and parsing back.

Example 3 — Large Numbers

Compress a big integer into a short scientific string.

JavaScript
(123456).toExponential(2);  // "1.23e+5"
Try It Yourself

How It Works

123456 is about 1.23 × 105, so the exponent is +5.

Example 4 — Tiny Numbers

Very small magnitudes use a negative exponent.

JavaScript
(0.0000123).toExponential();  // "1.23e-5"
Try It Yourself

How It Works

Moving the decimal five places right gives 1.23, so the exponent is -5.

Example 5 — Format Then Parse

Build an exponential string from a parsed value — an MDN-style round trip.

JavaScript
Number.parseFloat("123e-2").toExponential(1);  // "1.2e+0"
Try It Yourself

How It Works

"123e-2" parses to 1.23. Formatting with one fraction digit yields "1.2e+0".

🚀 Common Use Cases

  • Science & engineering UIs — show measurements in a consistent scientific layout.
  • Logging huge / tiny values — keep console output readable.
  • Charts & axes — label scales that span many orders of magnitude.
  • Export / CSV — compact numeric text for very large ranges.
  • Teaching scientific notation — demonstrate mantissa and exponent live.
  • Not for money — prefer toFixed or a decimal library for currency.

🧠 How toExponential() Builds the String

1

Read the number

Must be a Number primitive or wrapper.

Input
2

Normalize mantissa

One digit before the decimal; pick the exponent.

Scale
3

Apply fractionDigits

Round or expand digits after the point (0–100).

Digits
4

Return string

Form like "1.23e+5"; original number unchanged.

📝 Notes

  • Does not change the number — returns a new string.
  • fractionDigits outside 0–100 throws RangeError.
  • Always uses exponential form (unlike toPrecision, which may stay plain).
  • Rounding follows the same floating-point rules as other Number formatters.
  • Infinity and NaN return "Infinity" / "NaN", not expo strings.
  • For locale-aware formatting, use toLocaleString() with suitable options — not toExponential.

Browser & Runtime Support

Number.prototype.toExponential() is Baseline Widely available — part of JavaScript since early ECMAScript editions and supported in every modern browser and Node.js.

Baseline · Widely available

Number.prototype.toExponential()

Safe for production everywhere. Optional fractionDigits 0–100 works consistently across engines.

100% Universal support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Number.toExponential() Excellent

Bottom line: Use freely for scientific display. Prefer toFixed or decimal libraries for currency and exact decimal places.

Conclusion

Number.prototype.toExponential() turns any number into a clear scientific string, with optional control over mantissa digits. It is ideal for logs, science UIs, and values that span many orders of magnitude.

Continue with toFixed() for fixed decimals, toString() for base conversion, or return to the Number methods hub.

💡 Best Practices

✅ Do

  • Use parentheses for integer literals: (123456).toExponential(2)
  • Pick a small fractionDigits for readable charts and labels
  • Validate digits stay between 0 and 100
  • Parse with Number.parseFloat when you need the value again
  • Prefer toFixed when you need plain fixed decimals

❌ Don’t

  • Write 10.toExponential() without space/parens (syntax error)
  • Use exponential strings for currency amounts
  • Pass fractionDigits below 0 or above 100
  • Assume every engine prints -0 the same way
  • Confuse toExponential with toPrecision (different goals)

Key Takeaways

Knowledge Unlocked

Five things to remember about Number.toExponential()

Format numbers in scientific notation with optional digit control.

5
Core concepts
🔢 02

Digits

0–100

Param
e 03

Form

Always expo

Shape
04

Sign

Kept

Negatives
05

Safe

Baseline

Support

❓ Frequently Asked Questions

Number.prototype.toExponential() returns a string of the number in exponential (scientific) notation — one digit before the decimal point, then an e+ or e- exponent. Example: (77.1234).toExponential() is "7.71234e+1".
fractionDigits is an optional integer from 0 to 100 that sets how many digits appear after the decimal point. If you omit it, JavaScript uses as many digits as needed to represent the number. Values outside 0–100 throw a RangeError.
toExponential() always uses scientific notation. toFixed() uses fixed decimal places in plain form. toPrecision() picks a total significant-digit count and may use either plain or exponential form depending on the value.
Like other Number methods, (77).toExponential() needs parentheses (or a space) so the parser does not treat the dot as a decimal point. 77.toExponential() is a syntax error.
Yes. Number() or Number.parseFloat() accept strings like "1.23e+5". That is useful when you format for display, then parse again for math.
It is part of early ECMAScript and is Baseline Widely available — safe in every modern browser and Node.js.
Did you know?

In JavaScript source code you can also write numbers with exponents directly — 1.23e5 is the same value as 123000. toExponential() is the reverse direction: number → that style of text.

More Number Methods

Return to the hub for the growing Number.prototype collection.

Number methods hub →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful