Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <h1>Number preview tool</h1>

<form id="translate">
    <label for="number">number</label>
    <input type="number" id="number" value="12345.6789" required />
    <label for="notation">notation</label>
    <select id="notation">
    <label for="maximumfractiondigits">significant digits</label>
    <input type="number" id="maximumfractiondigits" value="2" min="0" max="9" step="1" required />
    <label for="style">style</label>
    <select id="style">
  <div class="currencyfield">
    <label for="currency">currency</label>
    <select id="currency">
  <div class="currencyfield">
    <label for="currencydisplay">currency display</label>
    <select id="currencydisplay">
  <div class="unitfield">
    <label for="unit">unit</label>
    <select id="unit">
  <div class="unitfield">
    <label for="unitdisplay">unit display</label>
    <select id="unitdisplay">

<table summary="translation">
    <tr><th>locale</th><th class="value">date / time</th>
  <tbody id="result">
    <tr><th title="US English">en-US</th><td></td></tr>
    <tr><th title="UK English">en-GB</th><td></td></tr>
    <tr><th title="Canadian English">en-CA</th><td></td></tr>
    <tr><th title="Australian English">en-AU</th><td></td></tr>
    <tr><th title="Spanish">es-ES</th><td></td></tr>
    <tr><th title="Mexican Spanish">es-MX</th><td></td></tr>
    <tr><th title="French">fr-FR</th><td></td></tr>
    <tr><th title="German">de-DE</th><td></td></tr>
    <tr><th title="Italian">it-IT</th><td></td></tr>
    <tr><th title="Portuguese">pt-PT</th><td></td></tr>
    <tr><th title="Polish">pl-PL</th><td></td></tr>
    <tr><th title="Welsh">cy-GB</th><td></td></tr>
    <tr><th title="Icelandic">is-IS</th><td></td></tr>
    <tr><th title="Kazakh">kk-KZ</th><td></td></tr>
    <tr><th title="Afrikaans">af-AF</th><td></td></tr>
    <tr><th title="Zulu">zu-ZU</th><td></td></tr>
    <tr><th title="Russian">ru-RU</th><td></td></tr>
    <tr><th title="Arabic (Saudi Arabia)">ar-SA</th><td></td></tr>
    <tr><th title="Hebrew">he-HE</th><td></td></tr>
    <tr><th title="Bengali">bn-BN</th><td></td></tr>
    <tr><th title="Vietnamese">vi-VI</th><td></td></tr>
    <tr><th title="Chinese">zh-CN</th><td></td></tr>
    <tr><th title="Japanese">ja-JP</th><td></td></tr>

<output id="code" />


                * {
  box-sizing: border-box;
  padding: 0;
  margin: 0;

form {
  display: flex;
  flex-wrap: wrap;
  gap: 1em;

body {
  font-family: sans-serif;
  font-size: 1em;
  margin: 1em;
  color: #333;
  background-color: #fff;

h1 {
  font-size: 1.5em;
  font-weight: normal;
  margin-bottom: 0.5em;

input, select {
  display: block;
  width: 8em;
  font-family: inherit;
  font-size: 1em;
  padding: 0.2em;

label {
  display: block;
  font-size: 0.9em;
  padding: 0 0 0.2em;
  color: #666;

table {
  width: 100%;
  font-size: 0.9em;
  font-variant-numeric: tabular-nums;
  table-layout: fixed;
	border-spacing: 0;
	border-collapse: collapse;
	empty-cells: show;
  margin: 1em 0;
  border: 2px solid #999;

thead {
  border-bottom: 1px solid #999;

tr th:first-child {
  width: 6em;
  border-right: 1px solid #999;

th, td {
  vertical-align: top;
  text-align: right;
  padding: 0.2em 0.4em;

th {
  background-color: rgba(0,0,0,0.2);

td, th.value {
  text-align: left;

tbody tr:nth-child(2n) {
  background-color: rgba(0,0,0,0.05);

output {
  display: block;
  font-family: monospace;
  white-space: nowrap;
  padding: 0.5em;
  font-size: 1em;
  color: #0d0;
  background-color: #111;
  user-select: all;
  overflow: auto;
  border-radius: 5px;

.currencyfield {
  display: none;

form.currency .currencyfield {
  display: block;

.unitfield {
  display: none;

form.unit .unitfield {
  display: block;


                // DOM nodes
  translate = document.getElementById('translate'),
  code = document.getElementById('code'),
  result = [];

  .forEach(r => result.push(
      { input: r.textContent, output: r.nextElementSibling }

// form event handlers
translate.addEventListener('submit', e => e.preventDefault());
translate.addEventListener('change', update);

// update results
function update() {
  // get field values
    field = getFields(translate),
    value = parseFloat(field.number),
    opt = {
      notation: field.notation,
      maximumFractionDigits: parseFloat(field.maximumfractiondigits),
  translate.className =;
  switch ( {
    case 'currency':
      opt.currency = field.currency;
      opt.currencyDisplay = field.currencydisplay;
    case 'unit':
      opt.unit = field.unit;
      opt.unitDisplay = field.unitdisplay;
  // update code snippet
  code.textContent = `new Intl.NumberFormat("[locale]", ${ JSON.stringify(opt) }).format( ${ value } );`;
  // update results
  result.forEach(r => {
    r.output.textContent = new Intl.NumberFormat(r.input, opt).format(value);

// return an object with all form fields
function getFields(form) {
  const field = {};
  Array.from(form.elements).forEach(e => {
    if ( field[] = (e.value || '').trim();
  return field;