What's the difference between str.isdigit, isnumeric and isdecimal in Python?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
str.isdecimal(), str.isdigit(), and str.isnumeric() all check whether every character in a string belongs to a numeric category, but they do not mean the same thing. The difference comes from Unicode character classes. In practice, isdecimal is the strictest, isnumeric is the broadest, and isdigit sits in the middle.
isdecimal() Is the Strictest
isdecimal() returns True only for characters that are decimal digits in Unicode. This is the closest match to ordinary base-10 digits used in standard number strings.
Typical results:
- '
"123"is decimal.' - Arabic-Indic digits such as
"١٢٣"are also decimal. - Superscript digits such as
"²"are not decimal. - Roman numerals such as
"Ⅳ"are not decimal.
If your goal is "can this string be treated like a plain integer string," isdecimal() is often the safest starting point.
isdigit() Accepts More Digit-Like Characters
isdigit() includes decimal digits, but it also accepts some characters that are considered digits without being normal decimal characters, such as superscript digits.
This means:
- '
"123"returnsTrue.' - '
"²"also returnsTrue.' - '
"Ⅳ"still returnsFalse.'
That makes isdigit() slightly broader than isdecimal(). It is useful when digit-like Unicode characters should count, but it can surprise you if you expected only standard decimal input.
isnumeric() Is the Broadest
isnumeric() covers everything from isdigit() plus additional Unicode numeric characters such as vulgar fractions and some numeral symbols.
Here:
- '
"123"is numeric.' - '
"²"is numeric.' - '
"Ⅳ"is numeric.' - '
"½"is numeric.'
This method answers a Unicode question, not a parsing question. A string can be "numeric" according to Unicode and still not be acceptable to int() or float() in the form you expect.
Compare the Three Directly
The easiest way to remember the relationship is:
Conceptually:
- Every decimal string is also a digit string and a numeric string.
- Some digit strings are not decimal strings.
- Some numeric strings are neither decimal nor digit strings.
So the inclusion order is:
- '
isdecimalinsideisdigit' - '
isdigitinsideisnumeric'
Choose Based on What You Need to Accept
These methods are often used as if they were input validators for parsing numbers, but that is only partly true. The right choice depends on the business rule:
- Use
isdecimal()for ordinary integer-like user input. - Use
isdigit()if superscript or similar digit characters should count. - Use
isnumeric()only when broad Unicode numeric recognition is actually desired.
If you want to validate Python number syntax such as negative numbers, decimal points, or scientific notation, none of these methods is enough because "-12" and "3.14" all return False. In that case, actual parsing with int(), float(), or decimal.Decimal is a better strategy.
Common Pitfalls
- Assuming all three methods are synonyms.
- Using
isnumeric()when only ordinary decimal digits should be accepted. - Expecting these methods to validate signed numbers or decimal points.
- Assuming a
Trueresult guaranteesint()orfloat()will behave the way you want. - Forgetting that Unicode digit categories are broader than ASCII digits.
Summary
- '
isdecimal()is the strictest and matches standard decimal digit characters.' - '
isdigit()includes decimal digits plus some digit-like Unicode characters such as superscripts.' - '
isnumeric()is the broadest and includes fractions and numeral symbols.' - These methods answer Unicode character questions, not full numeric parsing questions.
- For actual numeric input validation, parsing is often safer than character-category checks.

