The invention discloses a visualized code generation method based on the combination of an API (application programming interface) and script definition, which is characterized in that visualized programs are hierarchically organized, each program is composed of a plurality of elements, each element is composed of a plurality of visualized pages, and each visualized page is composed of a plurality of graphic symbols and data links. The method comprises the following steps that: a front-end processor reads visualized project files and imports the visualized project files into a symbol library so as to form visualized page data in a memory, starts a script engine, analyzes and executes a script, calls an API library in the script, and accesses the attribute of a symbol; and after the execution of the script is completed, a back-end processor organizes text paragraphs, and outputs a code text. According to the method disclosed by the invention, through using a conventional function of providing a programming platform of the API, the code of a symbol can be defined in a script, so that the dependence on a system software interface is shaken off, and good expansibility is provided for the application personnel; meanwhile, the script can be written, and under the condition of not modifying graphic programs and programming platforms, application scenes can be switched, and then corresponding object codes can be output.