Ansible in a Minute · Ansible Core ·
Use human_readable to format a byte count
Short answer
Pipe a byte count through human_readable so the message shows a size people can read, such as 10.00 KB.
Subscribe for updates
Get an email whenever we publish new guides and blog posts. Unsubscribe anytime.
By subscribing you agree we may email you about Ansible in a Minute and related Level Up Labs updates. We store your address in the same lead sheet as our contact form.
Request
print 10240 as human_readable so the message is 10.00 KB
Example
A quick heads-up: Every environment is different. Review and test this example before you run it on systems you care about.
---
# Prompt: print 10240 as human_readable so the message is 10.00 KB
- name: Print 10.00 KB message
hosts: all
gather_facts: false
tasks:
- name: Print 10.00 KB message
ansible.builtin.debug:
msg: "{{ 10240 | human_readable }}"How it works
human_readable converts a byte count into a string with a unit. 10240 becomes 10.00 KB. Use this filter when people must read the size. Use human_to_bytes when a module needs a raw byte integer.
When to use it
- Printing disk or file sizes in a recap
- Showing a quota or image size in KB, MB, or GB
Requirements
- Ansible: >=2.14
Validation
- Syntax validated
- Not execution-tested
- Last verified 2026-10-02
Notes
Pass unit="G" to force gigabytes. Pass isbits=True to treat the value as bits. human_to_bytes is the inverse filter. It turns 10.00 KB back into 10240.
Reference
- Human readable (Ansible docs)
Built for every Ansible use case in every organization
BacklogZero can generate this kind of automation in your environment, just like it did here.