Home Explore Blog CI



nushell

commands/docs/format_bits.md
c1fa4c5b8d893e281e620619fb5f6e3449f81b35b18b0d7d0000000300000693
---
title: format bits
categories: |
  conversions
version: 0.104.0
conversions: |
  Convert value to a string of binary data represented by 0 and 1.
usage: |
  Convert value to a string of binary data represented by 0 and 1.
editLink: false
contributors: false
---
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->

# `format bits` for [conversions](/commands/categories/conversions.md)

<div class='command-title'>Convert value to a string of binary data represented by 0 and 1.</div>

## Signature

```> format bits {flags} ...rest```

## Parameters

 -  `...rest`: For a data structure input, convert data at the given cell paths.


## Input/output types:

| input    | output |
| -------- | ------ |
| binary   | string |
| bool     | string |
| duration | string |
| filesize | string |
| int      | string |
| record   | record |
| string   | string |
| table    | table  |
## Examples

convert a binary value into a string, padded to 8 places with 0s
```nu
> 0x[1] | format bits
00000001
```

convert an int into a string, padded to 8 places with 0s
```nu
> 1 | format bits
00000001
```

convert a filesize value into a string, padded to 8 places with 0s
```nu
> 1b | format bits
00000001
```

convert a duration value into a string, padded to 8 places with 0s
```nu
> 1ns | format bits
00000001
```

convert a boolean value into a string, padded to 8 places with 0s
```nu
> true | format bits
00000001
```

convert a string into a raw binary string, padded with 0s to 8 places
```nu
> 'nushell.sh' | format bits
01101110 01110101 01110011 01101000 01100101 01101100 01101100 00101110 01110011 01101000
```

Chunks
5a28160e (1st chunk of `commands/docs/format_bits.md`)
Title: format bits
Summary
The `format bits` command converts a value into a string of binary data represented by 0s and 1s. It supports various input types such as binary, boolean, duration, filesize, integer, record, string, and table. The output is a string representation of the binary data, padded to 8 places with 0s.