Google and Facebook will be forced to pay media companies in Australia for publishing their news under what the government says is a world-first mandatory code of conduct.

Treasurer Josh Frydenberg said on Monday that negotiations between the tech giants and traditional media platforms had failed to result in a voluntary arrangement and that the competition watchdog would unveil a draft code by the end of July.

Australia's government has pledged to tackle the "power imbalance" between the digital giants and traditional media, adding to a barrage of global action against Google and Facebook. Regulators worldwide have been trying to loosen the tech giants' grip on advertising, search engines, news, data and elections.

Mr Frydenberg said the government was "very conscious of the challenges" of forcing the companies to pay for news content, after efforts in France and Spain had failed. The payment model could be based on the cost of preparing journalistic content, or the value added to the digital platform by using it, he said.

The announcement is the government's latest response to a sweeping report by the Australian Competition and Consumer Commission that raised concerns about the use and storage of personal data and the erosion of the mainstream media. In December, Australia said it would set up a special unit within the competition watchdog to monitor digital platforms.