ASCII Art from Image Generator
Convert any image to ASCII art instantly. Adjust width, character set, colors & contrast. Copy or download your ASCII masterpiece.
About
ASCII art generation maps pixel luminance values to typographic glyphs ordered by visual density. The conversion relies on the ITU-R BT.601 luma formula L = 0.299R + 0.587G + 0.114B to reduce each pixel block to a single brightness scalar, then selects a character whose ink-to-whitespace ratio approximates that scalar. Errors compound quickly: a poorly ordered character ramp produces muddy output, wrong aspect ratio correction distorts proportions, and naive downsampling destroys fine detail. This tool handles all three failure modes with block averaging that compensates for the ~2:1 height-to-width ratio of monospace glyphs.
The generator supports multiple character ramps from 10 to 70 density levels, optional Sobel edge detection for line-art style output, and per-character color preservation using the original pixel RGB values. Output widths range from 20 to 200 characters. Note: photographic images with subtle gradients require wider output and denser ramps to preserve tonal range. High-contrast logos and icons produce legible results even at 40 characters wide.
Formulas
The core conversion maps pixel brightness to a character index in the density ramp.
Where R, G, B are the red, green, and blue channel values in range [0, 255], and L is the resulting luminance in the same range.
Where i is the character index and n is the total number of characters in the ramp. For inverted mode, the index is reversed: i = (n − 1) − i.
Block averaging downsamples the image. Each output character represents a block of bw × bh pixels:
Where W is image width in pixels, cols is desired output character width, and the factor 2 corrects for monospace character aspect ratio (~1:2 width:height).
For edge detection mode, the Sobel operator computes gradient magnitude at each pixel:
Where Gx and Gy are the horizontal and vertical convolution results of the 3×3 Sobel kernels applied to the grayscale image.
Reference Data
| Character Ramp | Name | Glyph Count | Best For | Density Range |
|---|---|---|---|---|
@%#*+=-:. | Standard | 10 | General use, logos | Full tonal |
$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\|()1{}[]?-_+~<>i!lI;:,"^`'. | Detailed | 70 | Photographs, portraits | High precision |
#@+=- | Simple | 6 | Small images, thumbnails | Low detail |
█▓▒░ | Blocks | 5 | Retro pixel art | Uniform steps |
10 | Binary | 3 | Silhouettes, high contrast | Two-tone |
| Aspect Ratio Correction | ||||
| Parameter | Typical Value | Explanation | ||
| Char width | 1.0 ch | Horizontal unit in monospace font | ||
| Char height | ~2.0 ch | Line-height makes chars taller than wide | ||
| Correction factor | 0.5 | Sample half as many rows as columns | ||
| Luminance Coefficients (ITU-R BT.601) | ||||
| Red weight | 0.299 | Human eye red sensitivity | ||
| Green weight | 0.587 | Dominant perceptual channel | ||
| Blue weight | 0.114 | Lowest eye sensitivity | ||
| Sobel Kernels | ||||
| Gx | [-1,0,1; -2,0,2; -1,0,1] | Horizontal gradient | ||
| Gy | [-1,-2,-1; 0,0,0; 1,2,1] | Vertical gradient | ||
| Magnitude | √Gx2 + Gy2 | Edge strength per pixel | ||
| Recommended Output Widths | ||||
| Icons / Emojis | 20 - 40 chars | Simple shapes | ||
| Logos | 60 - 80 chars | Medium detail | ||
| Photographs | 100 - 150 chars | Tonal gradients | ||
| High detail | 150 - 200 chars | Maximum fidelity | ||