Input options
Results
| # | Original token | Normalized boolean | Integer value |
|---|
Example data table
This example assumes the standard mapping TRUE → 1 and FALSE → 0.
| # | Input token | Normalized boolean | Integer value | Notes |
|---|---|---|---|---|
| 1 | true | TRUE | 1 | Generic synonym for logical true. |
| 2 | false | FALSE | 0 | Generic synonym for logical false. |
| 3 | yes | TRUE | 1 | Accepted in generic mode as true. |
| 4 | no | FALSE | 0 | Accepted in generic mode as false. |
| 5 | 1 | TRUE | 1 | Numeric representation of true when allowed. |
| 6 | 0 | FALSE | 0 | Numeric representation of false when allowed. |
Formula used
The calculator supports two main formulas depending on the selected mode.
-
Per-value mapping:
For each recognized boolean value
b:f(b) = awhenb = TRUE, andf(b) = cwhenb = FALSE, whereaandcare your chosen integers. -
Bitfield integer mode:
A sequence of booleans is converted into bits using TRUE → 1 and FALSE → 0.
For bits
d0, d1, …, dn-1:-
If the first token is the least significant bit:
Integer = Σ di · 2i. -
If the first token is the most significant bit:
Integer = Σ di · 2n-1-i.
-
If the first token is the least significant bit:
- When numeric handling is enabled, non-zero numeric tokens map to TRUE, zero to FALSE.
- Invalid tokens are reported and ignored in the bitfield integer computation.
How to use this calculator
- Select a conversion mode: per-value mapping or bitfield integer.
- Choose the input boolean format or define custom tokens if needed.
- Optionally enable numeric handling for non-zero values interpreted as TRUE.
- For per-value mapping, pick integer values for TRUE and FALSE.
- For bitfield mode, set bit order, optional width, and padding side.
- Enter your boolean values separated by commas, spaces, semicolons, or line breaks.
- Click Convert, review results, then export as CSV or PDF.
Typical use cases for boolean to integer conversion
Converting booleans into integers is useful whenever you need compact flag storage or numeric calculations based on logical states.
- Encoding feature flags in configuration tables or lookup rows.
- Storing many TRUE or FALSE values as a single bitfield integer.
- Building machine-learning features where booleans must be numeric inputs.
- Preparing export-ready datasets for spreadsheets, databases, or dashboards.
- Integrating legacy systems that expect numeric codes instead of booleans.
Supported boolean tokens and normalization rules
The calculator normalizes many common textual and numeric representations into TRUE or FALSE before applying your chosen integer mapping.
-
Generic format accepts
true,false,yes,no,on,off,1, and0. - Dedicated formats limit accepted tokens to a strict pair, for cleaner validation.
- Optional numeric mode treats non-zero numbers as TRUE and zero as FALSE.
- Custom mode lets you define your own TRUE and FALSE words or codes.
- Any token outside these rules is marked invalid and highlighted in the table.
Best practices for accurate boolean to integer mappings
Consistent conventions and clear documentation help avoid confusion when sharing converted data with other teams or systems.
- Decide a standard mapping (for example TRUE → 1, FALSE → 0) for your project.
- Keep the same mapping in databases, reports, and code to avoid misinterpretation.
- Use strict formats when importing external files to catch invalid tokens early.
- For bitfields, write down how each bit position corresponds to a named flag.
- Include exported CSV or PDF examples in technical documentation for future reference.
Frequently asked questions
1. Can I convert many boolean values at once?
Yes. In mapping mode each boolean token becomes a separate integer row. In bitfield mode all recognized booleans combine into one integer value, displayed in decimal, binary, and hexadecimal formats.
2. What kind of sources can I paste into the input?
You can paste boolean fields exported from spreadsheets, logs, databases, configuration files, or application traces. As long as tokens follow supported formats, the calculator will normalize values and generate usable integers.
3. How do numeric tokens like -1 or 2 get interpreted?
Enable the numeric handling switch and keep the generic format selected. Any non-zero numeric token will map to TRUE, zero will map to FALSE, and results follow your chosen mapping integers.
4. How can I catch bad or unexpected boolean values?
Use strict formats like true or false or 1 or 0 when importing sensitive or messy data. Invalid tokens appear clearly marked, so you can correct them before trusting exported integers.
5. When should I choose bitfield mode instead of mapping?
Bitfield mode is ideal when you treat multiple boolean flags as a single packed integer. It is useful for permissions, feature flags, protocol headers, embedded registers, or compact storage structures.
6. Should I export results as CSV or PDF for sharing?
Use the CSV export for spreadsheets or database imports. Use the PDF export when sharing reviewed conversions with clients, auditors, or teammates. Both include header information and the full mapped results table.