Live data from Hacker News

Ask HN: Should IDs be strings or numbers in your codebase?

news.ycombinator.com

1–3 of 3 posts

Ask HN: Should IDs be strings or numbers in your codebase?

#1
At work we're debating whether entity IDs should be typed as strings or numbers throughout our stack (API contracts, frontend, etc.).

Database auto-increments happen to be integers, but we never perform arithmetic on IDs – they're opaque identifiers.

My take: IDs are identifiers, not numbers. Typing them as strings makes this explici and makes migrating to UUIDs or other formats painless.

Am I missing a good reason to keep them as numbers?