File size changer
Change a file to an exact size: when growing it reports the bytes to add and three fill strategies (zeros, deterministic bytes, repeating the original), when shrinking it gives the kept byte range from the head or tail, with no re-encoding.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Resize plan
Bytes to add or cut plus the kept range.
Enter the original and target sizes to calculate
Original bytes: 0 · Target bytes: 0 · Difference: 0 · Kept bytes: 0
What this tool does
- Find upload limits: truncate a file to a byte count and locate where a system starts rejecting it.
- Create fixed-size samples: pad a few hundred bytes up to 2 MB to test how a program handles large files.
- Strip trailing junk: keep the first N bytes and drop a log or checksum block appended at the end.
- Reason about integrity checks: knowing the target size and fill strategy lets you predict whether a stored hash will still match.
Example
Input
1024,2048
Output
原文件:1024 B(1 KB / 0.001 MB) 目标大小:2048 B(2 KB / 0.002 MB) 换算依据:1 KB = 1024 B、1 MB = 1 048 576 B、1 GB = 1 073 741 824 B 需要补足:1024 B(1 KB / 0.001 MB) 填充方式:全 0x00 字节(最省空间、最可预测,任何程序都能识别)。 操作顺序:先原样保留原文件的全部字节,再追加上述填充字节。 预计输出:2048 B(2 KB / 0.002 MB)(与原文件相差 +1024 字节) 提示:修改后的文件内容已改变,若原文件有校验值(MD5/SHA),修改后必然不匹配。
Binary prefixes: 1 KB = 1024 B, 1 MB = 1,048,576 B; truncation does not re-encode, so the output is exactly the target size.
Frequently asked questions
What is added when growing the file?
One of three strategies: all 0x00 bytes (smallest and most predictable), a deterministic byte cycle from a seed (reproducible for hashing), or repeating the original content from the head so the file looks continuous. In every case the original bytes are kept untouched and the fill is appended.
Which part survives when shrinking?
By default the head is kept and the tail dropped, but you can keep the tail instead. The result prints the exact kept range — for example turning 2048 bytes into 1024 with tail-keeping keeps bytes 1024–2047.
Is anything re-encoded or compressed?
No. Truncation only drops bytes and padding only appends them, so the output is exactly the target size without line-ending conversions or other encoding surprises.
Why does it warn about hashes?
Any byte change invalidates MD5/SHA checksums. The warning is always printed so you do not assume that only the size changed.
What is the optional third input?
A unit override for the target size. By default both sizes share one unit; 1048576,2,MB means 'turn 1,048,576 bytes into 2 MB', which helps with cross-unit conversions.
What is the size limit?
2 GB. Browser handling of single files above that is unreliable, so use dd (Linux/macOS) or fsutil (Windows) on the command line instead.
Keywords:文件大小修改文件体积file resize截断文件填充字节补足大小文件测试