---
title: Building More Humane Software With humanize.js
description: -
image: https://product.hubspot.com/hs-fs/msfillustration.png
---

[Engineering](https://product.hubspot.com/blog/topic/engineering)

# Building More Humane Software With humanize.js

[ Bryan Ash ](https://product.hubspot.com/blog/author/bryan-ash)

 on Feb 5, 2013

As front-end developers, we're always looking to make the software we create as friendly as possible for actual humans to use.

![](https://product.hubspot.com/hs-fs/msfillustration.png)

We're frequently called on to transform all kinds of data — currencies, dates, times, arrays, and objects — into human-friendly versions for display. We'll often end up writing one-off functions for these small tasks. Which can be deceptively simple when you start out, so it doesn't *feel* like you're creating a maintenance burden for yourself, but in fact, you are.

Sometimes we can get away with using built-in methods, like `Date.parse()` or some fancy type conversion. But, that often doesn't go far enough. Simple string concatentation just doesn't cut it.

So here at HubSpot we improved on the best parts of current formatting libraries to create [Humanize](https://github.com/hubspot/humanize). This library has been helpful in creating a consistent, *human* voice throughout our applications. It has a simple API, and it's both performant and well tested.

### What Is It?

Humanize is an **"object to string"** formatting library. Unlike other libraries that only let you format strings, Humanize helps you convert different types of data to human-readable text, like turning an array into a comma-separated list ([oxford comma](http://en.wikipedia.org/wiki/Serial_comma) optional).

**Examples:**

```
Humanize.dictionary({apples: 'red', banana: 'yellow'}) // 'apples are red, bananas are yellow'
```

```
Humanize.oxford(items, 3) // "apple, orange, banana, and 2 others"
```

```
Humanize.formatNumber(123456789, 2) // "123,456,789.00"
```

```
Humanize.ordinal(22) // "22nd"
```

```
Humanize.filesize(Math.pow(1000, 4)) // "931.32 Gb"
```

```
Humanize.truncate('long text is good for you', 19) // "long text is goo..."
```

Naturally, Humanize also includes optimized versions of basic string formatting methods (`truncate`, `pluralize`, etc.), but there are (intentionally) no date formatting methods. For that, we highly recommend checking out [moment.js](http://momentjs.com/).

Humanize ([github](https://github.com/hubspot/humanize)) is written in [CoffeeScript](http://coffeescript.org/) (because we **love **CoffeeScript) and compiled using [Grunt](http://gruntjs.com/), complete with Jasmine specs. As always, send us a pull request if you have any ideas for improvement. Or if you're just a regular human (that is, not a developer), please leave a comment on this post and let us know other ways we can make our output more human.

Image via [masterdata.se](http://www.masterdata.se/r/string_format_for_javascript/)

*This is part of a series of posts on a bunch of new open source software released by HubSpot developers.*

* *

*  
*

[Share on Twitter](https://twitter.com/intent/tweet?url=https%3A%2F%2Fproduct.hubspot.com%2Fblog%2Fhumanize-js-making-the-internet-more-humane)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fproduct.hubspot.com%2Fblog%2Fhumanize-js-making-the-internet-more-humane)[Share via email](mailto:info@example.com?&subject=&body=https%3A%2F%2Fproduct.hubspot.com%2Fblog%2Fhumanize-js-making-the-internet-more-humane)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fproduct.hubspot.com%2Fblog%2Fhumanize-js-making-the-internet-more-humane)

## Recommended Articles

<https://product.hubspot.com/blog/a-human-approach-to-product-content>

[UX](https://product.hubspot.com/blog/topic/ux)

## [A Human Approach to Product Content](https://product.hubspot.com/blog/a-human-approach-to-product-content)

 At HubSpot, we’re working to build a more diverse and inclusive place to work. We want to make sure that HubSpot is the kind of place where everyone ...

[ Elizabeth Dunn (She/Her) ](https://product.hubspot.com/blog/author/elizabeth-dunn)

 on Nov 2, 2018

<https://product.hubspot.com/blog/new-hubspot-nav>

[Product](https://product.hubspot.com/blog/topic/product)

## [The Journey of Redesigning HubSpot’s Global Navigation (Again)](https://product.hubspot.com/blog/new-hubspot-nav)

[ Lara Tacito (She/Her) ](https://product.hubspot.com/blog/author/lara-tacito)

 on May 28, 2024

<https://product.hubspot.com/blog/modern-java-at-hubspot>

[Engineering](https://product.hubspot.com/blog/topic/engineering)

## [Modern Java at HubSpot](https://product.hubspot.com/blog/modern-java-at-hubspot)

 HubSpot’s core technology stack has been through a lot of change and iteration. What started as a simple content system based off a C# framework has ...

[ Whitney Sorenson (He/Him) ](https://product.hubspot.com/blog/author/whitney-sorenson)

 on Jan 20, 2016

## Join our subscribers

Sign up here and we'll keep you updated on the latest in product, UX, and engineering from HubSpot.

[Subscribe to the newsletter

](https://product.hubspot.com/blog/humanize-js-making-the-internet-more-humane#subscription-popup)

[Back](https://product.hubspot.com/blog/humanize-js-making-the-internet-more-humane#)

## Get Connected

The latest engineering, UX, and product news from the HubSpot Product Blog, straight to your inbox.

Next

Not using [HubSpot](https://www.hubspot.com/) yet?

Search Term:

** Search HubSpot.com ** Search the blog

Load more