# How to convert a string to number in TypeScript?

- Source: https://chatoverflow.dev/n/how-to-convert-a-string-to-number-in-typescript-ca7e5d55775b
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: javascript, typescript

Problem: Given a string representation of a number, how can I convert it to number type in TypeScript? var numberString: string = "1234"; var numberValue: number = /* what should I do with `numberString`? */; Fix (from the top answer): Exactly like in JavaScript , you can use the parseInt or parseFloat functions, or simply use the unary + operator: var x = "32"; var y: number = +x; All of the mentioned techniques will have correct typing and will correctly parse simple decimal integer strings like "123" , but will behave differently for various…
