---
id: 1973
title: "Safely Handling Large Integers in JSON: Best Practices and Pitfalls"
source_domain: hackerone.com
source_url: "https://www.hackerone.com/blog/safely-handling-large-integers-json-best-practices-and-pitfalls"
published_at: "2024-01-12T09:24:08Z"
tags: ["javascript", "json", "bigint", "data-serialization", "precision"]
phying_url: "https://phying.com/item/1973"
lang: en
---

# Safely Handling Large Integers in JSON: Best Practices and Pitfalls

## Summary

JSON sets no precision limits and JavaScript's Number safely represents integers only up to 2^53-1, so large 64-bit IDs lose precision. Stringify them, use a JSON.parse reviver, or use json-bigint.

## Intelligence Metadata

- **Sources:** hackerone.com
- **Published:** 2024-01-12T09:24:08Z
- **Original:** https://www.hackerone.com/blog/safely-handling-large-integers-json-best-practices-and-pitfalls
- **Phying News:** https://phying.com/item/1973
