Random Dad Jokes With curl

Fetch a dad joke as plain text or JSON from a public API.

LinuxcurlnetworkapiLow risk
Run curl -s -H "Accept: text/plain" https://icanhazdadjoke.com/ to print a joke as text.

01Command

Command
$ curl -s -H "Accept: text/plain" https://icanhazdadjoke.com/

02What it does

icanhazdadjoke uses content negotiation: with Accept: text/plain it returns the joke alone, while Accept: application/json returns structured data. Set a descriptive User-Agent as the API asks, and use /search for keywords.

03Risk

RiskLow risk
Requirementscurl (preinstalled on most Linux distributions)
!Warning: Without the Accept header you receive an HTML page; always set it when scripting.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • icanhazdadjoke API
    icanhazdadjoke.com · vendor-doc · 2026-09-20
    Evidence: Documents the Accept header content negotiation and the /api endpoints.

Last verified: 2026-09-20 · Category: Network

06Related solutions