≡ Menu

Linux Convert an MP3 File to WAV Format

How do I convert an MP3 file to WAV format under Linux using a shell prompt?

There are plenty of tools that to convert an MP3 file into WAV format. I recommend mpg321 which is a free command-line mp3 player, which uses the mad audio decoding library.

Install mpg321 or mpg123

Type the following command under Debian / Ubuntu Linux, enter:

sudo apt-get install mpg321


sudo apt-get install mpg123

I recommend using mpg123 as it is updated frequently.

Install mpg123 under CentOS / RHEL / Fedora Linux

Turn on rpmforge repo and type the following command:

yum install mpg123

Convert an MP3 to WAV

The -w option will convert an .mp3 file to .wav file. The syntax is:

mpg123 -w output.wav input.mp3


mpg321 -w output.wav input.mp3

A Sample Shell Script Helper Function

Add the following to your ~/.bashrc startup file (tested with bash v3.x+):

	[[ $# -eq 0 ]] && { echo "mp3wav mp3file"; exit 1; }
	for i in "$@"
		# create .wav file name
		local out="${i%/*}.wav"
		[[ -f "$i" ]] && { echo -n "Processing ${i}..."; mpg123 -w "${out}" "$i" &>/dev/null  && echo "done." || echo "failed."; }

Use it as follows:

mp3towav *.mp3
mp3towav "this is a test.mp3"
ls *.wav
Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:

{ 15 comments… add one }
  • Metalx1000 November 3, 2009, 11:35 pm

    Sorry, I meant:
    ffmpeg -i input.mp3 output.wav

  • nixCraft November 4, 2009, 5:26 am

    @Metalx1000, nice, I’ve deleted your old post and kept only correct one.

  • sanjay November 5, 2009, 5:59 am


    Is there any tool/command in Fedora to convert mp4 files to avi ?
    Or above command will also work for mp4 file.


    • nixCraft November 5, 2009, 6:16 am

      Command line tools:

      1. mencoder
      2. ffmpeg

      Gui tools:

      1. avidemux
  • gemuet November 5, 2009, 8:07 am

    is there a tool tool to convert .wmv/wma to mp3/mp4 or any other format which totem can easily play?

  • yoander (sedlav) November 5, 2009, 3:41 pm

    Another gui tool SoundConverter

  • gemuet November 5, 2009, 4:57 pm

    Thanks man.
    I appreciate.

  • Metalx1000 November 5, 2009, 7:24 pm

    Thanks Vivek Gite.

    ffmpeg -i input.wmv output.mp4
    That will convert the wmv to mp4 with default settings, which may not be the best quality.
    For more option on converting to mp4 with ffmpeg check out this post:

  • gemuet November 6, 2009, 8:08 am

    I appreciate your help man.

  • Jesper January 2, 2012, 4:48 pm

    Very nice – except you cant SIGHUP the script :)

  • Romanenko Bogdan January 25, 2013, 6:02 pm

    Thank’s. Use your article to convert mp3 to wav.

  • Roland August 27, 2014, 2:45 pm

    Don’t put ‘exit’ in a bash function! I ran ‘mp3towav’ with no options, and my terminal window vanished.

    • Mathieu April 15, 2016, 7:54 am

      You didn’t look before hey? Copy/paste is good but one has to make sure to evaluate/understand before using! Enough said, happened to me too hahahahhaha. I solve the “potential issue” by replacing:

      echo “mp3wav mp3file”; exit 1;


      echo “usage: mp3towav filenames”;

  • hezhixiong July 7, 2015, 9:24 am

    How do I convert a WAV file to MP3 format under Linux using a shell prompt?

  • StephaneAG November 8, 2015, 4:21 pm

    Hi there, thanks for the ffmpeg quickie, was handy to call the following ;p

    for file in ./*.mp3; do ffmpeg -i "${file}" "${file%.*}.wav"; done;

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , , , , , , , , , , , , , ,