---
title: "Discussion on \"How to keep undefined values in JSON.stringify\" | Hashnode"
description: "Discussion on \"How to keep undefined values in JSON.stringify\". The JSON spec does not allow undefined values, so when you try to stringify an object that contains an undefined value, the key will get removed:\nconst person = { name: 'Peter', age: undefined };\n\nJSON.stringify(person);\n// '{\"name\":\"Peter\"}'\n\nThere ..."
url: "https://hashnode.com/posts/how-to-keep-undefined-values-in-jsonstringify/6315de60360c57fcaa77ae85"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How to keep undefined values in JSON.stringify](https://petermekhaeil.hashnode.dev/how-to-keep-undefined-values-in-jsonstringify?utm_source=hashnode&utm_medium=feed)

The JSON spec does not allow undefined values, so when you try to stringify an object that contains an undefined value, the key will get removed: const person = { name: 'Peter', age: undefined }; JSON.stringify(person); // '{"name":"Peter"}' There ...

Aug 22, 2022 · 1 min read · petermekhaeil.hashnode.dev  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)

## Written by

[Peter Mekhaeil](https://hashnode.com/@petermekhaeil)

@petermekhaeil · Singapore

  
[View profile](https://hashnode.com/@petermekhaeil)

Software Engineer

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
