JSON Syntax

Can json keys be numbers?

Yes, JSON keys can be numbers, but they must be enclosed in double quotes and are treated as strings. For example, {"123": "value"} is valid JSON where "123" is a string key, not a numeric key. When this JSON is parsed in JavaScript, you can access the value using bracket notation: obj["123"]. However, dot notation like obj.123 causes a syntax error. Using numeric keys is generally discouraged because it creates confusion about data types and makes code less readable. If you need numeric identifiers, consider using them as values in a more descriptive object structure or as array indices instead. Most style guides recommend descriptive string keys for better code maintainability and clarity in JSON structures.
Last updated: December 23, 2025

Still have questions?

Can't find the answer you're looking for? Please reach out to our support team.