This invention discloses an automatic generation method of commodity code. The commodity code contains external code which is composed of prefix and suffix. The prefix is automatically generated after inputting the basic commodities information into computers, and the suffix is the serial number. The commodity code also includes the inner code ISN, commercial code and security code. The ISN is also formed by prefix and suffix. The prefix is the computer time when the commodity code is generated, and the suffix is the serial number. The commercial code is automatically generated by the user's code name and the foreign code. The security code is a number of automatic allocation Arabic numerals while the computer produces the ISN. The use of this invention to carry on the code for commodity, is standard, universal, practical, and can achieve the region commodity information management and transaction, independently carry on the different region maintenance of the commodity code, independently carry on the commodity security, and interpret the commodity information. It is applicable to the commodity information management system, the e-commerce system, the commodity information retrieval system, and also can be used in protecting the security.