# How to Disable Holehe Color Output for Log Parsing and Automation

> Disable Holehe color output for easier log parsing and automation. Learn to use the --no-color flag for plain text terminal output.

- Repository: [Palenath/holehe](https://github.com/megadose/holehe)
- Tags: how-to-guide
- Published: 2026-08-15

---

**Use the `--no-color` flag to strip ANSI color codes from Holehe's terminal output, producing plain text suitable for log parsers and automation pipelines.**

Holehe's color-coded output helps humans scan results quickly, but those same ANSI escape sequences break standard log-processing tools. According to the megadose/holehe source code, the tool provides a built-in mechanism to disable colorization entirely. This guide explains how color handling works under the hood and how to leverage the `--no-color` option for reliable automation.

## How Holehe Implements Color Output

Colorization in Holehe is centralized in **[`holehe/core.py`](https://github.com/megadose/holehe/blob/main/holehe/core.py)** through a simple conditional pattern that wraps the `termcolor` library.

### The print_color Function

The helper function `print_color` (lines 106-112) acts as a gatekeeper for all colored output:

```python
def print_color(text, color, args):
    """Print text with color unless --no-color is specified."""
    if args.nocolor:
        return text
    return colored(text, color)

```

When `args.nocolor` is **False** (the default), the function returns `colored(text, color)` from `termcolor`, embedding ANSI escape sequences. When **True**, it returns the raw `text` unchanged.

### CLI Flag Definition

The `--no-color` argument is registered in the argument parser at lines 86-88:

```python
parser.add_argument(
    "--no-color",
    action="store_true",
    dest="nocolor",
    help="Disable colored output"
)

```

This stores `True` in `args.nocolor` when present, propagating through to every `print_color` call.

## Disabling Colors for Log Parsing

### Command-Line Usage

Append `--no-color` to any Holehe invocation to produce plain ASCII output:

```bash
holehe user@example.com --no-color

```

**Output comparison:**

| With colors (default) | Without colors (`--no-color`) |
|-----------------------|-------------------------------|
| `[+]` in green | `[+]` plain text |
| `[-]` in magenta | `[-]` plain text |
| `[x]` in yellow | `[x]` plain text |
| `[!]` in red | `[!]` plain text |

### Practical Parsing Examples

Pipe plain output directly into standard Unix tools without struggling with escape sequences:

```bash

# Extract confirmed accounts only

holehe user@example.com --no-color | grep '^\[+\]'

# Count rate-limited sites

holehe user@example.com --no-color | grep '\[x\]' | wc -l

# Structured extraction with awk

holehe user@example.com --no-color | awk '/^\[+\]/ {print $2}'

```

### Programmatic Disabling in Python

When embedding Holehe in automation scripts, set `nocolor` explicitly on the arguments namespace:

```python
import argparse
from holehe.core import print_result

# Construct arguments with color disabled

args = argparse.Namespace()
args.nocolor = True          # Disable color output

args.onlyused = False
args.verbose = False

# ... populate remaining attributes ...

# Generate plain-text results

print_result(data, args, email, start_time, websites)

```

This bypasses `termcolor` entirely, ensuring consistent output across different terminal environments.

## Key Files and Dependencies

| File | Purpose |
|------|---------|
| [`holehe/core.py`](https://github.com/megadose/holehe/blob/main/holehe/core.py) | Contains `print_color()` and `--no-color` CLI definition (lines 86-88, 106-112) |
| [`setup.py`](https://github.com/megadose/holehe/blob/main/setup.py) | Declares `termcolor` as a required dependency |
| [`holehe/instruments.py`](https://github.com/megadose/holehe/blob/main/holehe/instruments.py) | Progress bar instrumentation (separate from color handling) |

## Summary

- **Default behavior**: Holehe emits ANSI-colored symbols via `termcolor` for visual clarity.
- **Disable mechanism**: The `--no-color` flag sets `args.nocolor = True`, forcing `print_color()` to return raw strings.
- **Automation benefit**: Plain output eliminates escape sequences that corrupt `grep`, `awk`, `jq`, and log aggregators.
- **Implementation location**: All color logic resides in [`holehe/core.py`](https://github.com/megadose/holehe/blob/main/holehe/core.py) with centralized control through a single boolean flag.

## Frequently Asked Questions

### Does `--no-color` affect Holehe's exit codes or data structure?

No. The flag only modifies output formatting. Return codes, result dictionaries, and internal data processing remain identical. The change is strictly presentational within the `print_color` wrapper.

### Can I force color output even when piping to a file?

Holehe does not implement `FORCE_COLOR` or `CLICOLOR` environment variable support. Colors depend solely on the `--no-color` flag's absence. To preserve colors in a file, you would need to capture standard output normally and process it through a tool like `script` or `unbuffer`.

### What happens if `termcolor` is not installed?

The `termcolor` package is declared as a required dependency in [`setup.py`](https://github.com/megadose/holehe/blob/main/setup.py). If somehow missing, Holehe would fail at import time when [`holehe/core.py`](https://github.com/megadose/holehe/blob/main/holehe/core.py) attempts to `from termcolor import colored`, before any color logic executes.

### Does Holehe support automatic color detection based on terminal capabilities?

No. The megadose/holehe source code does not implement `isatty()` checks or `NO_COLOR` environment variable compliance. Color output is binary: enabled by default, disabled only via explicit `--no-color` flag.