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
Related Questions
Can json have duplicate keys?
Learn whether JSON can have duplicate keys, what happens when they occur, and why you should avoid them for data integrity and predictability.
Can json use single quotes?
Find out if JSON can use single quotes. Learn about JSON's strict double-quote requirement and why it differs from JavaScript syntax.
Can json have comments?
Learn whether JSON supports comments and discover workarounds. Understand why standard JSON excludes comments and alternatives like JSON5.
Still have questions?
Can't find the answer you're looking for? Please reach out to our support team.