String Formatter
See what C# / .NET format strings produce: numeric formats, alignment, composite formatting and everyday string methods.
Numeric formatting
| Expression | Meaning | Result |
|---|
Padding & alignment
| Expression | Meaning | Result (boxed) |
|---|
Composite formatting — string.Format
Common string methods
| Expression | Meaning | Result |
|---|
Escape sequences & string literals
| Syntax | Meaning | Example |
|---|
About this tool
This page re-implements .NET's formatting rules in JavaScript so you can try format strings without compiling anything. Whole numbers are treated as int (or long when they do not fit), anything with a decimal point or exponent as double. D and X only work with integer types, exactly like in .NET.
- Standard formats (
F,N,C,P,E,Gwith a precision) round the exact binary value of a double and send exact halves to the even digit, like .NET Core 3.0 and later:0.125.ToString("F2")is0.12. - Custom formats first reduce a double to 15 significant digits and then round halves away from zero, so
1.005.ToString("0.00")is1.01.intandlongvalues are always exact. - A negative double that rounds to zero keeps its sign (
-0.001.ToString("0.00")is-0.00), as in .NET Core 3.0 and later. - Separators, currency symbols and percent placement come from your browser's locale data (ICU), which is also what .NET uses on Linux and macOS. Windows (NLS) data can differ slightly, for example in negative currency patterns.
- Custom formats support
0,#,.,,(grouping and ÷1000 scaling),%,‰,E+0/e-0,\escapes, quoted literals and up to three;sections.
Privacy
Everything is computed in your browser. Nothing is sent, stored or logged.