Explainshell API is a lightweight JSON API wrapper for explainshell. It takes shell commands as input and returns structured metadata for each component, including matched flags, commands, and their associated help text, with exact token positions. This makes it perfect for tools and frontend applications that need on-the-fly shell command explanations without scraping HTML. Ideal for interactive tutorials, terminal UIs, and intelligent CLI assistants.
- Parses and explains commands using explainshell
- Returns structured JSON responses with token positions
- Supports frontend and tool integration
git clone https://github.com/gryffus/explainshell-api.git
cd explainshell-apigit submodule update --init --recursivecurl -L -o ./dump.gz https://github.com/idank/explainshell/releases/download/db-dump/dump.gzdocker-compose build
docker-compose up -dThis will start both the explainshell service and the API wrapper.
You can now access the API at:
http://localhost:5000/api/explain?cmd=your+shell+command
Example:
curl "http://localhost:5000/api/explain?cmd=ls+-lh+--all"{
"getargs":"ls -lh --all",
"helptext":[
[
"list directory contents",
"help-0"
],
[
"<b>-l</b> use a long listing format",
"help-1"
],
[
"<b>-h</b>, <b>--human-readable</b>\n with <b>-l</b>, print sizes in human readable format (e.g., 1K 234M 2G)",
"help-2"
],
[
"<b>-a</b>, <b>--all</b>\n do not ignore entries starting with .",
"help-3"
]
],
"matches":[
{
"commandclass":"command0",
"end":2,
"helpclass":"help-0",
"match":"ls",
"spaces":" ",
"start":0,
"suggestions":[
]
},
{
"commandclass":"command0",
"end":5,
"helpclass":"help-1",
"match":"-l",
"spaces":" ",
"start":3,
"suggestions":[
]
},
{
"commandclass":"command0",
"end":6,
"helpclass":"help-2",
"match":"h",
"spaces":" ",
"start":5,
"suggestions":[
]
},
{
"commandclass":"command0",
"end":12,
"helpclass":"help-3",
"match":"--all",
"spaces":" ",
"start":7,
"suggestions":[
]
}
],
"status":"success"
}Contributions are welcome! To contribute:
- Fork the repository
- Create a new branch for your feature or fix
- Make your changes
- Submit a pull request
This project wraps explainshell, which is licensed under the MIT License. This wrapper is provided under the same license.