# How to count the number of properties in a JavaScript object

> Learn how to count the number of properties in a JavaScript object using Object.keys() to get an array of its enumerable keys and reading the length property.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2018-12-07 | Topics: [JavaScript](https://flaviocopes.com/tags/js/) | Canonical: https://flaviocopes.com/how-to-count-properties-object-javascript/

Use the [`Object.keys()`](https://flaviocopes.com/javascript-object-keys/) method, passing the object you want to inspect, to get an array of all the (own) enumerable properties of the object.

Then calculate the length of that array by checking the `length` property:

```js
const car = {
  color: 'Blue',
  brand: 'Ford',
  model: 'Fiesta'
}

Object.keys(car).length
```

I said enumerable properties. This means their internal enumerable flag is set to true, which is the default. [Check MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties) for more info on this subject.
