File Validator
Validate file encoding, line endings, BOM presence, binary vs text detection, and file-specific integrity checks. Catch file hygiene issues before they cause problems.
Get the CLI Tool
Run the file validator locally as an MCP server, or try it online below.
npx @clinetools/file-validator
- Encoding detection — UTF-8, UTF-8 BOM, Latin-1, ASCII heuristics
- Line ending checks — detect LF, CRLF, and mixed inconsistencies
- BOM detection — find hidden UTF-8 BOM that breaks scripts and parsers
- Binary vs text — detect accidental binary content in text files
- Zero config — just run with npx
How to Use It
Three ways to validate your files — pick the one that fits your workflow.
Try Online
Use the interactive demo below to paste file content and validate it — no install needed.
Use via CLI
Run as a local MCP server and connect any MCP-compatible client.
Add to Cline / Claude Code
Add the tool to your MCP settings for instant access from your AI assistant.
MCP Client Configuration (Cline)
{
"mcpServers": {
"file-validator": {
"command": "npx",
"args": ["@clinetools/file-validator"]
}
}
}
Claude Code Configuration
# In your project's .mcp.json:
{
"mcpServers": {
"file-validator": {
"command": "npx",
"args": ["@clinetools/file-validator"]
}
}
}
Example: Validate a File
// Call the tool with a file path:
validate_file({ path: "src/index.ts" })
// Output:
{
"file": "src/index.ts",
"encoding": "utf-8",
"lineEndings": "LF",
"hasBOM": false,
"isBinary": false,
"lines": 142,
"issues": [],
"valid": true
}
Example: Integrity Check
// Prompt to your AI agent:
"Check all files in src/ for encoding and line ending issues"
// The agent calls:
validate_file({ path: "src/config.sh" })
// Output:
{
"file": "src/config.sh",
"encoding": "utf-8-bom",
"lineEndings": "mixed",
"hasBOM": true,
"isBinary": false,
"lines": 87,
"issues": [
{
"severity": "warning",
"message": "UTF-8 BOM detected - may break shell scripts",
"suggestion": "Remove BOM from shell scripts"
},
{
"severity": "warning",
"message": "Mixed line endings (54 LF, 33 CRLF)",
"suggestion": "Normalize to LF with git config core.autocrlf"
}
],
"valid": false
}
Try It Online
Paste file content below and validate it instantly. Or try one of our demo scenarios.
Paste File Content to Validate
Checks encoding, line endings, BOM, whitespace, and more
Paste file content and click Validate File to see results.
Issues Found
Why File Validation Matters
Invisible encoding and line ending issues cause some of the most frustrating debugging sessions. Catch them early.
Line Ending Wars
Windows uses CRLF (\r\n), Unix uses LF (\n). Mixed line endings in the same file cause git diffs to show every line as changed, break shell scripts, and create merge conflicts. Use git config core.autocrlf and validate consistency.
BOM Headaches
The UTF-8 BOM (byte order mark) is an invisible 3-byte prefix (\xEF\xBB\xBF) that breaks shell scripts, PHP files, JSON parsers, and CSV imports. Most editors add it silently. Always strip BOM from source code files.
Encoding Traps
Latin-1 and UTF-8 look identical for ASCII text but diverge on special characters. A file saved as Latin-1 will show garbled accents in UTF-8 readers. Always enforce UTF-8 across your project with .editorconfig.
File Size Monitoring
Large binary files accidentally committed to git balloon repository size permanently. Even after deletion, they persist in git history. Validate that text-expected files are actually text, and catch binary content before it enters your repo.
Trailing Newlines
POSIX defines a line as text terminated by a newline. Files missing a trailing newline can cause issues with cat, wc, shell script sourcing, and diff tools. Most linters and editors expect a final newline — validate it consistently.
Need Automated File Hygiene?
Our Pro plan includes automated file validation across your entire codebase with CI/CD integration and auto-fix.
View Plans