Number to words template
- HTML
- JavaScript
Write any number out in words, as an ordinal and digit by digit, for cheques and invoices.
A plain HTML and JavaScript app that writes numbers out in words. Enter any number, including decimals, and get it in words, as an ordinal like one millionth, digit by digit, and with the part after the decimal point spelled out. Use it for cheques, invoices and legal documents, or for reading numbers aloud.

What it does
- Words and ordinals
- Returns both one thousand and one thousandth, so it fits amounts and positions.
- Decimals too
- Spells out the digits after the decimal point, for amounts and measurements.
- One file
- The whole page is a single HTML file with its styles and script inside.
- Keeps your key private
- The page calls a Vercel function in api/, which holds the key, checks the input and limits each visitor to 10 conversions a minute.
- Runs locally in one command
- npm run dev serves the page and runs the api/ functions together, the same way Vercel does, with no CLI to install.
How it works
The Vercel function: it checks the number and calls Number to Words.
import { guard, callApi, respond, fail } from '../lib/apiverve.js';
// Up to 15 digits, an optional minus sign and up to 6 decimal places.
const NUMBER = /^-?\d{1,15}(\.\d{1,6})?$/;
/** GET /api/words?number=1234.5: the number written out in words, as an ordinal, and digit by digit. */
export async function GET(request) {
const blocked = guard(request);
if (blocked) return blocked;
const number = (new URL(request.url).searchParams.get('number') || '').replace(/,/g, '').trim();
if (!NUMBER.test(number)) return fail('Enter a number with up to 15 digits and 6 decimal places');
return respond(() => callApi('numbertowords', { query: { number } }));
}Deploy it
- Get a free API key
The free plan includes 200 credits a month, no card needed. Create your key.
- Deploy it
Click Deploy to Vercel. Vercel copies the repo to your GitHub account and asks for
APIVERVE_API_KEY: paste your key there. - Open your app
Vercel builds it and gives you a live URL, usually in about a minute. Every push to the repo redeploys it.
Try the Number to Words API — the call this template makes
No key required to try it. Get a key to use it in your app.
{
"status": "ok",
"error": null,
"data": {
"number": 975.07,
"words": "nine hundred seventy-five point zero seven",
"ordinal": "nine hundred seventy-fifth point zero seven",
"numberOfDigits_numeric": 3,
"numberOfDigits_words": "three",
"eachNumber": [
"nine",
"seven",
"five"
],
"afterDecimal": {
"number": "07",
"words": [
"zero",
"seven"
],
"numberOfDigits_numeric": 2,
"numberOfDigits_words": "two"
},
"locale": "en-US"
}
}