展示 HN:Deflate X-Ray,透视压缩文件
Show HN: Deflate X-Ray, See inside a compressed file

原始链接: https://hrih.si/projects/deflate-xray/

deflate x-ray 是一个基于浏览器的工具,用于解剖 DEFLATE 压缩文件,例如 .zip、.png、.gz 和网页。它使用自定义的 RFC 1951 解压器,展示重复文本如何变成指针,按位成本给字节着色,将每个复制字节追溯到其来源,并显示嵌套深度。它还报告字面量、指针和头部的比特消耗,同时校验校验和。用户可以在本地压缩输入文本或检查拖入的文件;一切都在浏览器内运行,无上传或网络请求。查看器只追踪前 150,000 字节和第一个 gzip 成员,且不支持 ZIP64、加密的 ZIP 条目或 zlib 预设字典。它是一个 AI 构建的夜间项目。页面还链接了关于电子表格作为早期氛围编程、杰文斯悖论与 AI 软件岗位,以及 AI 写作迹象的文章。

``` 黑客新闻 最新 | 过去 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 Show HN:Deflate X-Ray,查看压缩文件内部 ( hrih.si ) 4 分 由 DonAtimator 1 小时前 | 隐藏 | 过去 | 收藏 | 讨论 帮助 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请加入 YC | 联系 搜索: ```
相关文章

原文

What it is

Almost every compressed file, from .zip and .png to .gz and most web pages, uses the same method, DEFLATE. When text repeats, it’s replaced with a short pointer back to where it appeared before: copy 41 bytes from 57 back. Letters that come up often get shorter codes than rare ones.

A normal decompressor hands you only the result. deflate x-ray takes the file apart with its own decompressor, written from scratch, and shows you every pointer and what each byte cost.

What you can see

  • What each letter cost. Every byte is colored by its cost in bits. A letter stored as itself costs several bits. Inside a long copy it costs a fraction of one. The cheap repeats fade and the expensive surprises glow.
  • Where each piece came from. Click any byte to see the pointer that wrote it, its raw bits, and an arc back to the text it copied.
  • How deep the copying goes. In The House That Jack Built each verse copies the one before: copies of copies, 11 generations deep. A smooth PNG gradient goes 150 deep.
  • Where the bits went. How many went to letters, pointers and headers, with the file’s checksum checked against what came out.

Your files stay with you

Type anything, and your browser compresses it with its own built-in DEFLATE, so you see what a real compressor chose. Or drop a .gz, .zlib, .png or .zip file on the page. The page reads it in your browser. There’s no upload and no server involved: the page makes no network requests at all.

How it works

The decompressor follows RFC 1951 and is built like zlib’s reference decoder, puff. It handles all three block types and finds the DEFLATE stream inside gzip, zlib, PNG and ZIP files. One test checks that the headers, pointers and end-of-block codes add up to exactly the number of bits in the stream, for every block type. The whole viewer is one 45 KB page.

Honest limits

  • It paints the first 150,000 bytes of a stream. The statistics cover all of it.
  • Only the first member of a multi-member gzip file is traced.
  • ZIP64, encrypted ZIP entries and zlib preset dictionaries aren’t supported.
  • Bytes outside printable ASCII, including accented letters, show as ·.

How it was made

This is one of my nightly builds: an AI agent invents, builds and tests a new project every night. deflate x-ray came out of the 15 October 2026 run.

Have a related idea? Say hello
联系我们 contact @ memedata.com