How the .NET Format String Tester (C# ToString) Works
Format strings are one of those things you look up every time: is it MM or mm for months, what does "N" do in German, why does F2 round 2.675 down, how do I show millions with #,##0,,? This tester answers by running the format. Choose int, long, double, decimal, DateTime or DateTimeOffset, enter a value and a format string, pick one of five cultures, and see the result — plus a table of the common standard and custom formats for the same value, and a copyable C# snippet. The formatting engine is a line-by-line re-implementation of .NET 8's Number.Formatting and DateTimeFormat logic, with NumberFormatInfo and DateTimeFormatInfo data exported from .NET for InvariantCulture, en-US, en-GB, en-IN and de-DE. Because a formatter that is almost right is worse than none, it is tested against 24,540 values formatted by real .NET 8 — every numeric standard specifier with precision, custom patterns with sections, literals, scaling and exponents, and every date standard and custom specifier — and all of them match. Edge cases are explained where they bite: midpoint rounding differences between double and decimal, negative zero, two's-complement hex, Indian digit grouping, and time zone handling.
Numbers
Standard formats (C, D, E, F, G, N, P, R, X) and custom patterns (0, #, ., ,, %, ‰, E+0, sections with ;, quoted literals and \ escapes) are supported for int, long, double and decimal. Doubles use the exact binary value for standard formats with ties to even, and 15 significant digits for custom formats; decimals round half away from zero and keep trailing zeros in "G".
Dates
Standard formats (d D f F g G M O R s t T u U Y) expand to the culture's patterns; custom specifiers (yyyy, MMMM, dddd, HH, hh, tt, fff, FFF, K, zzz, quotes, %, \) are applied like .NET, including genitive month names (de-DE: "5. März") and the rule that "F" removes a preceding dot when the fraction is zero. R and u convert DateTimeOffset values to UTC.
Accuracy
The reference cases are generated by a small .NET console program included in the repository (tools-fixtures/dotnet-format), which also exports the culture data. The .NET and ICU versions are pinned and shown on this page; culture details such as default decimals and the space before AM/PM can differ with other ICU versions or with Windows NLS mode.
Time zones
DateTimeOffset carries its own offset. DateTime with Kind=Utc prints "Z" for K and +00:00 for zzz. DateTime with Kind=Unspecified is treated by .NET as local time for zzz and U, so the tool asks for the server's offset instead of guessing.