Binary to Integer Converter

Converts a list of binary strings (one per line) back into base-10 integers, parsing an optional leading "-" as a sign and the rest as base-2 digits (sign-magnitude, not two's complement). A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-27

Overview

Introduction

This tool reads a list of sign-magnitude binary strings and converts each back into an ordinary base-10 integer.

It's the reverse of the Integer to Binary Converter: a leading "-" is treated as a sign, and the remaining digits are parsed as base-2.

What Is Binary to Integer Converter?

A converter that takes binary strings, one per line, and outputs the base-10 integer each one represents.

It expects sign-magnitude binary (an optional "-" plus binary digits), not a fixed-width two's-complement bit pattern.

How Binary to Integer Converter Works

Each line is checked against a pattern allowing only an optional leading "-" followed by digits 0 and 1.

The digits after any sign are parsed as a base-2 number using JavaScript's `parseInt` with radix 2.

If the line started with "-", the parsed magnitude is negated.

When To Use Binary to Integer Converter

Use it to decode binary strings back into readable decimal numbers, especially output from the companion Integer to Binary Converter.

It's useful for checking binary homework, puzzles, or quick manual calculations.

Features

Advantages

  • Simple, readable sign-magnitude format that doesn't require picking a bit width.
  • Clear validation that flags exactly which line has an invalid character.

Limitations

  • Does not decode fixed-width two's-complement bit patterns; a leading 1 bit is not treated as a sign bit here.
  • Requires digits to be strictly 0 or 1; other characters (spaces, other digits) invalidate the line.

Examples

Positive binary string

Input

1101

Output

13

Negative binary string

Input

-101

Output

-5

Best Practices & Notes

Best Practices

  • If your binary came from a fixed-width two's-complement source, convert it with the Unsigned Integer to Signed Converter instead of this tool.

Developer Notes

Validates each line with `/^-?[01]+$/` before calling `parseInt(digits, 2)`, so malformed input fails with a specific per-line error rather than silently producing `NaN`.

Binary to Integer Converter Use Cases

  • Decoding binary output from the Integer to Binary Converter
  • Checking binary arithmetic homework or puzzles
  • Quickly reading a list of binary values as decimal

Common Mistakes

  • Pasting a fixed-width two's-complement pattern and expecting the high bit to be treated as a sign bit; it isn't here.
  • Including spaces or grouping characters (like "1101_0010") in a line, which isn't accepted.

Tips

  • Use the companion Integer to Binary Converter to generate valid sign-magnitude input for testing.

References

Frequently Asked Questions