tools/java/java format string
// javanew

java format string

live preview of String.format and MessageFormat output

// browser
// preview appears here
// prohistory syncpro·bulk generation via APIproupgrade →

// about this tool

Java has two string formatting systems: String.format (printf-style %s, %d, %f specifiers with flags, width, and precision) and MessageFormat ({0}, {1,number,currency} with type and style). This tool parses your format string, detects each placeholder, lets you supply values for each one, and shows the formatted output live.

// when to use

  • Verify that a String.format call produces the expected output before shipping
  • Figure out the right flags for zero-padded integers or comma-grouped numbers (%,d vs %05d)
  • Test a MessageFormat pattern with different numeric values before using it in an i18n bundle
  • Understand what %.2f vs %10.2f produces for a given float

// faq

What is the difference between String.format and MessageFormat?
String.format uses C-style % specifiers (%s, %d, %f) and is the most common choice for single-language apps. MessageFormat uses {0}, {1} positional placeholders and adds type-aware formatting ({0,number,currency}, {0,date,short}) — it is designed for internationalized messages where argument order may differ between locales.
Is the preview 100% identical to Java output?
It is very close for the most common specifiers. Locale-specific formatting (decimal separators, currency symbols) uses the browser's Intl API which may differ from the JVM's default locale. For production validation, test in your actual Java environment.
// history
Pro Cloud Sync — upgrade
no operations yet