How to Format Compact Numbers with the JavaScript
![How to Format Compact Numbers with the JavaScript](https://www.freecodecamp.org/news/content/images/size/w2000/2023/01/Format-Compact-Numbers.png)
Sometimes it can be difficult to fit large numbers into your site or app's layout, especially if you have to display several of them together. As a result, a lot of modern sites and apps use the same format to display large numbers in a compact way. For example,
Sometimes it can be difficult to fit large numbers into your site or app's
layout, especially if you have to display several of them together.
As a result, a lot of modern sites and apps use the same format to display large
numbers in a compact way. For example, displaying 123,000 as 123K.
freeCodeCamp's and Instagram profiles using compact number format.You
can do this by writing a custom format function, using a third-party library,
or, best of all, using a built-in JavaScript API.
![](https://glebbahmutov.com/blog/images/test-react-number-format/phone-test.png)
Testing React Number Format Component Example
freeCodeCamp on LinkedIn: How to Format Compact Numbers with the
freeCodeCamp on LinkedIn: How to Format Compact Numbers with the
![](https://glebbahmutov.com/blog/images/test-react-number-format/values.png)
Testing React Number Format Component Example
Gerard Hynes on LinkedIn: Learn the Eleventy Static Site Generator
![](https://elijahmanor.com/images/format-js-numbers/caniuse.jpg)
Natively Format JavaScript Numbers
![](https://i.ytimg.com/vi/FUngCjDzFDo/hq720.jpg?sqp=-oaymwEhCK4FEIIDSFryq4qpAxMIARUAAAAAGAElAADIQj0AgKJD&rs=AOn4CLCFNKk2p8SgarpozZnyq64s-QmY5A)
Phone number formatting in Javascript (3 minutes)
![](https://miro.medium.com/v2/resize:fit:687/1*6BPGIrHoCMLDpw3qGUT-_Q.png)
Build a Real-time Collaboration Service with Node.js and gRPC
![](https://cdn.sanity.io/images/3do82whm/next/81741cb9b27f665ee80459f500068bdb8cea0ede-4800x3600.png?w=800&h=600&fit=clip&auto=format)
Mendoza - The totally non-human readable diff format for structured JSON documents
![](https://www.cssscript.com/wp-content/uploads/2024/01/live-number-format.webp)
Real-Time Number/Currency Formatting With liveNumberFormat.js Library
freeCodeCamp on LinkedIn: How to Format Compact Numbers with the
Florin Lungu on LinkedIn: How to Format Compact Numbers with the