System.FormatException: Input string was not in a correct format
int.Parse/decimal.Parse/Convert.ToInt32 got a string that isn’t a valid number — empty, contains text, or uses another culture’s decimal separator.
Seen on:
.NET
Meaning
“1,5” fails under en-US, “1.5” fails under de-DE. Empty strings and whitespace also throw. Use TryParse and an explicit CultureInfo.
Common causes
- Empty or non-numeric string
- Culture-specific decimal/thousand separators
- Currency symbols or spaces
- Parsing user input without validation
⚡ Quick fix
- Use int.TryParse / decimal.TryParse
- Pass CultureInfo.InvariantCulture for machine data
- Trim and validate input
Detailed fix by platform
C#
- csharp
if (!decimal.TryParse(text, NumberStyles.Number, CultureInfo.InvariantCulture, out var amount)) return BadRequest("Invalid amount");
How to diagnose
- Value — Exact string
- Culture — CurrentCulture on server
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in .NET
- NullReferenceException System.NullReferenceException: Object reference not set to an instance of an object
- FileNotFoundException assembly Could not load file or assembly 'X, Version=…' or one of its dependencies
- InvalidOperationException InvalidOperationException: Unable to resolve service for type 'X' while attempting to activate 'Y'
Other ways to find it
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 7 Oct 2026