Justice Minister Shane Rattenbury has admitted to previously taking MDMA, following calls for pill testing at music festivals in New South Wales.

Mr Rattenbury played a key role in establishing the first pill testing trial in Australia at Groovin' The Moo in Canberra last year.

In a joint letter with Ms Faehrmann, Mr Rattenbury called on Premier Gladys Berejiklian to consider a trial in the state, after suspected overdoses at Australian music festivals resulted in the deaths of six young people this summer.