use JSON; my %data = (name => "Mike", age => 20, email => "mike@perlmonks.org", pass => "IAmGroot"); print encode_json(\%data); #edited thanks to marto __DATA__ {"age":20,"pass":"IAmGroot","email":"mike.org","name":"Mike"}