Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including ordinal with all npm packages installed. Try it out:

var ordinal = require("ordinal")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

ordinal v1.0.3

Module to provide the ordinal letters following a numeral


build status Version

Module to provide the English ordinal letters following a numeral.

If other languages are required, please submit an issue.



npm install --save ordinal


yarn add ordinal


Numbers only, anything else will throw a TypeError.

var ordinal = require('ordinal')

ordinal(1) // '1st'
ordinal(2) // '2nd'
ordinal(3) // '3rd'
ordinal(4) // '4th'

ordinal(11) // '11th'
ordinal(12) // '12th'
ordinal(13) // '13th'

ordinal(21) // '21st'
ordinal(22) // '22nd'
ordinal(23) // '23rd'
ordinal(24) // '24th'

To get just the indicator:

var indicator = require('ordinal/indicator')

indicator(1) // 'st'
indicator(2) // 'nd'
indicator(3) // 'rd'
indicator(4) // 'th'

indicator(11) // 'th'
indicator(12) // 'th'
indicator(13) // 'th'

indicator(21) // 'st'
indicator(22) // 'nd'
indicator(23) // 'rd'
indicator(24) // 'th'

License MIT

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free