H magic bytes (.h)
.h file signature: 23 69 66 6E 64 65 66 20 | text/x-chdr
Category: Source Code
The .h header file format is a plain-text source file used in the C and C++ programming ecosystems, with conventions established by the language community and toolchain maintainers. It is used to declare functions, types, macros, and constants for inclusion in source files, supporting modular program design and reusable interfaces. Header files are generally safe, but they may contain preprocessor directives and code that affect compilation; older projects may use them as part of legacy codebases.
Magic Bytes
Offset 0
23 69 66 6E 64 65 66 20
Sources: Apache Tika
Validation Code
How to validate .h files in Python
def is_h(file_path: str) -> bool:
"""Check if file is a valid H by magic bytes."""
signature = bytes([0x23, 0x69, 0x66, 0x6E, 0x64, 0x65, 0x66, 0x20])
with open(file_path, "rb") as f:
return f.read(8) == signature
How to validate .h files in Node.js
function isH(buffer: Buffer): boolean {
const signature = Buffer.from([0x23, 0x69, 0x66, 0x6E, 0x64, 0x65, 0x66, 0x20]);
return buffer.subarray(0, 8).equals(signature);
}
How to validate .h files in Go
func IsH(data []byte) bool {
signature := []byte{0x23, 0x69, 0x66, 0x6E, 0x64, 0x65, 0x66, 0x20}
if len(data) < 8 {
return false
}
return bytes.Equal(data[:8], signature)
}
API Endpoint
/api/v1/h
curl https://filesignature.org/api/v1/h
See the full API documentation for all endpoints and parameters.
Related Formats
Frequently Asked Questions
What is a .h file?
A .h file is identified by the magic bytes 23 69 66 6E 64 65 66 20 at byte offset 0. The .h header file format is a plain-text source file used in the C and C++ programming ecosystems, with conventions established by the language community and toolchain maintainers. It is used to declare functions, types, macros, and constants for inclusion in source files, supporting modular program design and reusable interfaces. Header files are generally safe, but they may contain preprocessor directives and code that affect compilation; older projects may use them as part of legacy codebases.
What are the magic bytes for .h files?
The magic bytes for H (.h) files are 23 69 66 6E 64 65 66 20 at byte offset 0. These bytes identify the file format more reliably than the extension alone.
How do I validate a .h file?
To validate a .h file, read the first bytes of the file and compare them against the known magic bytes (23 69 66 6E 64 65 66 20) at offset 0. This is more reliable than checking the file extension alone, as extensions can be renamed.
What is the MIME type for .h files?
The primary MIME type for .h files is text/x-chdr.
Is it safe to open .h files?
H (.h) files are generally safe to open. They are classified as low risk because they primarily contain data rather than executable code. However, always ensure files come from a trusted source.