# Zig Printing Format Specifier
## Metadata
**Status**:: #x
**Zettel**:: #zettel/fleeting
**Created**:: [[2025-11-14]]
## Synopsis
| **input** | `{}` | `{s}` | `{any}` |
| ------------- | ------------ | ------------ | ----------- |
| "s" | compileError | s | { 115 } |
| 1 | 1 | compileError | 1 |
| S{ .m = 1 } | S{ .m = 1 } | compileError | S{ .m = 1 } |
| Custom Format | S(m=1) | S(m=1) | S(m=1) |
## Custom Format
```zig
const std = @import("std");
const S = struct {
m: u32,
pub fn format(
self: *const S,
comptime fmt: []const u8,
options: std.fmt.FormatOptions,
writer: anytype,
) !void {
_ = fmt;
_ = options;
try writer.print("S(m={d})", .{self.m});
}
};
```
- `fmt`: The specifier. It is empty for `{any}`.
- `options`: See the next section.
## Options
```
{[position][specifier]:[fill][alignment][width].[precision]}
```
- `[position]`: Argument index for positional formatting (rarely needed).
- `[specifier]`: Type specifier, e.g. `d` (decimal), `s` (string), `any` (custom format), etc.
- `:`: Introduces advanced formatting options.
- `[fill]`: Character to pad empty space.
- `[alignment]`: `<` (left), `^` (center), `>` (right).
- `[width]`: Minimum width of formatted output.
- `.`: Introduces precision for numeric types.
- `[precision]`: Number of decimal places for floating-point, or precision for other types.