File Utilities and Editing
Overview
A collection of file utility operations for working with MIME types, file paths, content formatting (CSV/JSON), base64 encoding/decoding, and cryptographic hashing. Use this tool when you need to manipulate file metadata, transform data formats, or generate hashes without touching the filesystem.
Actions
file-mime-type-detect
Detects the MIME type of a file based on its filename/extension. Supports documents, images, audio, video, archives, and programming languages.
Required fields:
input(string) — The filename to analyze (e.g.,report.pdf,photo.jpg)
Example:
{
"action": "file-mime-type-detect",
"input": "quarterly-report.xlsx"
}
Returns the MIME type (application/vnd.openxmlformats-officedocument.spreadsheetml.sheet), file extension, and category (application).
file-extension-from-mime
Looks up the standard file extension for a given MIME type.
Required fields:
input(string) — A MIME type string (e.g.,image/png,application/pdf)
Example:
{
"action": "file-extension-from-mime",
"input": "audio/mpeg"
}
Returns the matching extension (.mp3) and whether a match was found.
file-size-format
Converts a raw byte count into a human-readable size string (KB, MB, GB, etc.).
Required fields:
input(string) — File size in bytes as a string (e.g.,"5242880")
Example:
{
"action": "file-size-format",
"input": "5242880"
}
Returns "5.00 MB" along with the numeric value and unit.
file-path-parse
Breaks a file path into its component parts: directory, filename, name, and extension.
Required fields:
input(string) — A file path to parse (e.g.,/home/user/documents/report.pdf)
Example:
{
"action": "file-path-parse",
"input": "/home/user/documents/report.pdf"
}
Returns the directory (/home/user/documents), filename (report.pdf), name (report), extension (.pdf), and whether the path is absolute.
file-path-join
Joins multiple path components into a single path. You can provide components as a comma-separated string in input, or use the input, input2, and input3 fields for up to three components.
Required fields:
input(string) — First path component, or a comma-separated list of all components
Optional fields:
input2(string) — Second path component (when not using comma separation)input3(string) — Third path component (when not using comma separation)
At least 2 path components are required.
Example (comma-separated):
{
"action": "file-path-join",
"input": "/home/user, documents, report.pdf"
}
Example (separate fields):
{
"action": "file-path-join",
"input": "/home/user",
"input2": "documents",
"input3": "report.pdf"
}
Returns the joined and normalized path (/home/user/documents/report.pdf).
file-path-normalize
Cleans up a messy file path by resolving .., ., and redundant separators.
Required fields:
input(string) — A file path to normalize (e.g.,/home/user/../user/./documents//file.txt)
Example:
{
"action": "file-path-normalize",
"input": "/home/user/../user/./documents//file.txt"
}
Returns the cleaned path (/home/user/documents/file.txt).
file-csv-to-table
Parses CSV content and renders it as a formatted ASCII table. The first row is treated as headers.
Required fields:
input(string) — CSV content as a string
Example:
{
"action": "file-csv-to-table",
"input": "Name,Age,City\nAlice,30,New York\nBob,25,London\nCarol,35,Tokyo"
}
Returns the row count, column count, headers list, a formatted ASCII table, and the parsed data as structured arrays.
file-json-pretty-print
Formats a compact JSON string with indentation for readability.
Required fields:
input(string) — A valid JSON string
Optional fields:
indent(integer, default: 2) — Number of spaces per indentation level (0-8)
Example:
{
"action": "file-json-pretty-print",
"input": "{\"name\":\"Alice\",\"age\":30,\"address\":{\"city\":\"New York\",\"zip\":\"10001\"}}",
"indent": 4
}
Returns the formatted JSON string along with original and formatted lengths.
file-json-minify
Removes all unnecessary whitespace from a JSON string to produce the most compact representation.
Required fields:
input(string) — A valid JSON string (can include whitespace/indentation)
Example:
{
"action": "file-json-minify",
"input": "{\n \"name\": \"Alice\",\n \"age\": 30\n}"
}
Returns the minified JSON, original and minified lengths, and the percentage reduction in size.
file-base64-encode
Encodes a text string to base64 using UTF-8 encoding.
Required fields:
input(string) — The text to encode
Example:
{
"action": "file-base64-encode",
"input": "Hello, World! This is a secret message."
}
Returns the base64-encoded string along with original and encoded lengths.
file-base64-decode
Decodes a base64 string back to UTF-8 text.
Required fields:
input(string) — A valid base64-encoded string
Example:
{
"action": "file-base64-decode",
"input": "SGVsbG8sIFdvcmxkISBUaGlzIGlzIGEgc2VjcmV0IG1lc3NhZ2Uu"
}
Returns the decoded text along with encoded and decoded lengths.
file-hash-generate
Generates a cryptographic hash of the provided text content.
Required fields:
input(string) — The content to hash
Optional fields:
hash_algorithm(string, default:"sha256") — Algorithm to use:md5,sha1,sha256, orsha512
Example:
{
"action": "file-hash-generate",
"input": "This is the content of my document that I want to verify.",
"hash_algorithm": "sha256"
}
Returns the hex-encoded hash digest, the algorithm used, content length, and hash length.
Common Workflows
Workflow 1: Validate and format incoming data
- Use
file-mime-type-detectwith a received filename to confirm the file type - Use
file-size-formatto display the file size in a readable format - If the content is JSON, use
file-json-pretty-printto format it for review
Workflow 2: Content integrity verification
- Use
file-base64-decodeto decode a received base64 payload - Use
file-hash-generateto compute a SHA-256 hash of the decoded content - Compare the hash against an expected value to verify integrity
Workflow 3: Build and normalize file paths
- Use
file-path-jointo combine directory and filename components - Use
file-path-normalizeto clean up the resulting path - Use
file-path-parseto extract individual components for further processing
Important Notes
- All operations are stateless text transformations. This tool does not read from or write to the filesystem.
- The
inputfield must always be provided as a string, even for numeric values like file sizes. - CSV parsing treats the first row as column headers.
- JSON operations (
pretty-printandminify) will return an error if the input is not valid JSON. - Base64 encoding/decoding uses UTF-8. Binary data that is not valid UTF-8 cannot be decoded with
file-base64-decode. - Unknown file extensions default to the MIME type
application/octet-stream. - The
indentparameter only applies tofile-json-pretty-printand must be between 0 and 8.







