# Is there a way to format the default integer value or any value entered using a comma as a thousand-separator when using a st.number\_input() widget?

**URL:** <https://discuss.streamlit.io/t/is-there-a-way-to-format-the-default-integer-value-or-any-value-entered-using-a-comma-as-a-thousand-separator-when-using-a-st-number-input-widget/79879>\
**Category:** Using Streamlit\
**Tags:** streamlit-elements, streamlit, debugging\
**Created:** [August 28, 2024, 11:11am UTC](https://discuss.streamlit.io/t/is-there-a-way-to-format-the-default-integer-value-or-any-value-entered-using-a-comma-as-a-thousand-separator-when-using-a-st-number-input-widget/79879 "2024-08-28T11:11:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![eurojourney](https://avatars.discourse-cdn.com/v4/letter/e/e56c9b/32.png) [@eurojourney](https://discuss.streamlit.io/u/eurojourney)\
**Post date:** [August 28, 2024, 11:11am UTC](https://discuss.streamlit.io/t/is-there-a-way-to-format-the-default-integer-value-or-any-value-entered-using-a-comma-as-a-thousand-separator-when-using-a-st-number-input-widget/79879/1 "2024-08-28T11:11:57Z")

</div>

Hi!  
I’ve read several posts and tried different things to get this to work, but so far I am not getting the desired results. I am using a st.number\_input() widget. The default value is an integer usally large, in the hundreds of thousands if not millions. The ideal situation would be to format the default value appearing when rendering the widget with the comma to separate thousands and make it easier to read, i.e. if the default value is 1000000, then when the widget is rendered it should indicate 1,000,000. I have tried different arguments for the format parameter with no luck. I do not want to convert this to text and then back to a number because it seems like it would require a “Submit” button, which I do not want to incorporate (This last statement based on an error I got when I was trying different options).

Any idea how to incorporate the comma/thousand separator when displaying the default integer in a st.number\_input() widget?

Below how it currently renders on my app:

![image](https://global.discourse-cdn.com/streamlit/original/3X/7/d/7d7673afd80074a67191fae9ea4480e2f2fda493.png)

---

<div class="post-metadata">

**Author:** ![Goyo](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/goyo/32/28219_2.png) [@Goyo](https://discuss.streamlit.io/u/Goyo)\
**Post date:** [August 28, 2024, 11:31am UTC](https://discuss.streamlit.io/t/is-there-a-way-to-format-the-default-integer-value-or-any-value-entered-using-a-comma-as-a-thousand-separator-when-using-a-st-number-input-widget/79879/2 "2024-08-28T11:31:26Z")

</div>

According to [the docs](https://docs.streamlit.io/develop/api-reference/widgets/st.number_input)

> Formatting is handled by [sprintf.js](https://github.com/alexei/sprintf.js).

which doesn’t seem to support thousand separators.

---

<div class="post-metadata">

**Author:** ![eurojourney](https://avatars.discourse-cdn.com/v4/letter/e/e56c9b/32.png) [@eurojourney](https://discuss.streamlit.io/u/eurojourney)\
**Post date:** [August 28, 2024, 11:44am UTC](https://discuss.streamlit.io/t/is-there-a-way-to-format-the-default-integer-value-or-any-value-entered-using-a-comma-as-a-thousand-separator-when-using-a-st-number-input-widget/79879/3 "2024-08-28T11:44:23Z")

</div>

Yeah, I looked into that, not sure if there is some kind of workaround… Thank you for the reply

---

<div class="post-metadata">

**Author:** ![edsaac](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/edsaac/32/47599_2.png) [@edsaac](https://discuss.streamlit.io/u/edsaac)\
**Post date:** [August 28, 2024, 2:43pm UTC](https://discuss.streamlit.io/t/is-there-a-way-to-format-the-default-integer-value-or-any-value-entered-using-a-comma-as-a-thousand-separator-when-using-a-st-number-input-widget/79879/4 "2024-08-28T14:43:24Z")

</div>

Consider upvoting the Github issue/discussion on that topic:

> <https://github.com/streamlit/streamlit/issues/1301>
>
> \### Problem
> 
> \*As a user:\* I want to format my number as I do with Python. 
> 
> …For example:
> \`\`\`python
> x = 1000000
> print(f"{x:,}")
> \# 1,000,000
> \`\`\`
> 
> \### Additional context
> 
> https://discuss.streamlit.io/t/format-integer-with-comma-using-python-printf/2344
> 
> \---
> 
> Community voting on feature requests enables the Streamlit team to understand which features are most important to our users.
> 
> \*\*If you'd like the Streamlit team to prioritize this feature request, please use the 👍 (thumbs up emoji) reaction in response to the initial post.\*\*

---

<div class="post-metadata">

**Author:** ![eurojourney](https://avatars.discourse-cdn.com/v4/letter/e/e56c9b/32.png) [@eurojourney](https://discuss.streamlit.io/u/eurojourney)\
**Post date:** [August 28, 2024, 4:47pm UTC](https://discuss.streamlit.io/t/is-there-a-way-to-format-the-default-integer-value-or-any-value-entered-using-a-comma-as-a-thousand-separator-when-using-a-st-number-input-widget/79879/5 "2024-08-28T16:47:48Z")

</div>

Done… looks like this is going to take a while…

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/streamlit/original/3X/c/f/cf4c2ee0d938358f82448c5fe4b9c3c91d7ce19c.svg) [@system](https://discuss.streamlit.io/u/system)\
**Post date:** [February 24, 2025, 4:48pm UTC](https://discuss.streamlit.io/t/is-there-a-way-to-format-the-default-integer-value-or-any-value-entered-using-a-comma-as-a-thousand-separator-when-using-a-st-number-input-widget/79879/6 "2025-02-24T16:48:12Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
