#6511·clap

Underscores in numeric literal args matching Rust source code behavior

Author: brodiealexanderCreated Sep 2, 2026Updated Sep 2, 2026
LabelsC-enhancementS-waiting-on-decisionA-parsingA-validators

Please complete the following tasks

I searched "rust clap underscore numeric literal" in a web search engine and searched for "underscore" in closed and open issues as well as discussions, so hopefully this is not a duplicate.

Clap Version

4.6.6

Describe your use case

I have trouble reading numeric arguments with repeated digits when running my programs. Having worked with the Rust ecosystem for a while, I tried formatting my input as 1_000_000.0 with hopes that it might work, but it did not.

Since this sort of digit grouping behavior is accepted in the source code for Rust as well as a few other modern languages, I figure I can't be the only one with this issue. This could be good for accessibility if implemented and is something i'd personally like to have in my programs.

Describe the solution you'd like

I am not that familiar with clap internals yet, but I suppose this could be done either as a pre-processing step like what argparse does or could be implemented at the parsing level. The motivation may also need to be documented somewhere for anyone endeavoring to implement custom number parsing (e.g. for complex numbers). The task should (I think) just involve using Rust's string replace function to replace '_' with '' or similar.

Alternatives, if applicable

No response

Additional Context

No response