Skip to content
Tezmy Tools

Printf Text Formatter

Fill a printf-style template with the values on each line

Use %s for text, %d for whole numbers, %f for decimals, %x for hex, %% for a percent sign.

3 lines formatted.

Runs in your browser. Nothing is uploaded.

About the Printf Text Formatter

If you know the printf or sprintf style from C, PHP, Python or shell scripts, this tool applies it to a list. Write a template with placeholders such as %s for text, %d for whole numbers, %f for decimals and %x for hexadecimal. Then paste one set of values per line, separated by commas, tabs or spaces, and every line is formatted. Width, padding, precision, signs and left alignment work as in the original, so a column of amounts can be rounded and lined up. It runs in your browser and the values are not uploaded.

Updated October 2026

How to use the Printf Text Formatter

  1. 1Type a template, for example Name: %s, age %d.
  2. 2Paste your values, one set per line.
  3. 3Choose how the values on a line are separated.
  4. 4Read the formatted lines on the right.
  5. 5Copy the result or download it.

Why format with a template

Reports, logs and generated code need consistent text. A template says once how a line should look, and the tool applies it to every row of data. It saves you from writing a loop or a spreadsheet formula, and the familiar printf codes mean no new syntax to learn.

It is also a quick way to test a format string before you put it into your program.

    The codes

    Most scripts use only a few: s, d, f and x. Widths and flags make columns line up. A percent sign is written as two percent signs. Numbers are rounded when you give a precision, and whole-number codes drop the decimal part.

    • %s text
    • %d whole number
    • %.2f two decimals
    • %05d zero padded
    • %x hexadecimal

    Differences from real printf

    This tool is built for text: values are read from your lines, not typed by a compiler. Unsupported codes are left as they are. Number words such as NaN are written when a value cannot be read as a number.

      Example

      With the template %-6s is %3d years old and owes %8.2f, the line Ann, 30, 1234.5 becomes Ann is 30 years old and owes 1234.50. The name is padded to six characters, the age to three, and the amount is rounded to two decimals and padded to eight characters. Each further line is formatted the same way.

      Using %05d turns 42 into 00042, and %x turns 255 into ff, which makes the tool useful for padding IDs and for quick base conversions.

        Phone and computer

        On a phone, paste into the box, adjust the template and the separator, and tap Copy to carry the result into another app. On a computer you can also download it as a file. The two boxes sit side by side on a wide screen and one above the other on a narrow one, so you can compare input and result without zooming. Nothing you paste is uploaded or stored. Format codes often involve other bases, so use Number Base Converter to check values in hex or binary. Text Formatter gives you simple clean-up options, and Add Prefix and Suffix to Lines adds fixed text around each line.

          Features

          • %s %d %i %u %f %e %g %x %X %o %b %c and %%
          • Width, padding and left alignment
          • Precision for decimals and text
          • Plus and space flags
          • Warns when a line has too few values
          • Private: nothing is uploaded

          Frequently asked questions

          What does %s, %d and %f mean?

          %s inserts text, %d inserts a whole number, and %f inserts a decimal number. Each takes the next value on the line.

          How do I round to two decimals?

          Use %.2f. The value 1234.5 becomes 1234.50, and with a width such as %8.2f it is padded to eight characters.

          How do I pad with zeros?

          Put a zero before the width: %05d turns 42 into 00042.

          How do I left-align text in a column?

          Use a minus sign: %-10s writes the text and pads with spaces on the right up to ten characters.

          What if a line has fewer values than placeholders?

          The missing placeholders are left empty and the note counts them so you can fix the data.

          Is my data uploaded?

          No. Formatting is done in your browser.

          Related tools